Pine Script v5 · Strategy
Volume fight strategy
A Pine Script v5 strategy built on VWMA (bull_vol, 11) and SMA (11). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 10000 in cash and pays 0.04 commission. 5 settings; defaults include Direction ANY, Search_range 11 and Smoothing_for_flat,% 15.
Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.
- Does Volume fight strategy repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 12 of 12 trades.
- How did Volume fight strategy do on BTCUSDT 1D with default settings?
- +92.03%
- From 26 Jan 2024 to 21 Oct 2026, over 45 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- What alerts does Volume fight strategy have?
- 2
- Bullish movement! LONG trading zone; Bearish movement! SHORT trading zone.
- Does Volume fight strategy run in Pine Script v6?
- No
- The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 45 before, 1 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
- Does Volume fight strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
BTCUSDT · 1D · default settings
- Volume difference
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +92.03%
- $9,203.16
- Buy and hold
- +102.5%
- same period
- Closed trades
- 45
- 14 won · 31 lost
- Profitable
- 31.1%
- of closed trades
- Profit factor
- 1.61
- gross profit ÷ gross loss
- Max drawdown
- 24.62%
- −$5,004.58
One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A short position was still open at the last bar. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
-
Note
Uses an argument v6 removed
when = on line 36, 37, 38, 39. The upgraded version below moves each call inside an if block.
Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| DirectionSelect the direction of trade.\n\nВыберите направление торговли. | ANY | string · options ['LONG', 'SHORT', 'ANY'] | entry Long entry Short |
| Search_rangeThe range of estimation of the predominance of bullish or bearish volume (quantity bars). The smaller the TF, the higher the range value should be used to filter out false signals.\n\nДиапазон оценки преобладания бычьего или медвежьего объема (количество баров). Чем меньше ТФ, тем выше следует использовать значение диапазона, чтобы отфильтровать ложные сигналы. | 11 | int · min 1 | avg_bull_vol avg_bear_vol diff_vol |
| Smoothing_for_flat,%Smoothing to reduce false signals and highlight the flat zone. If you set the percentage to zero, the flat zones will not be highlighted, but there will be much more false signals, since the indicator becomes very sensitive when the smoothing percentage decreases.\n\nСглаживание для уменьшения ложных сигналов и выделения зоны флета. Если выставить процент равным нулю, то зоны флета выделяться не будут, но будет гораздо больше ложных сигналов, так как индикатор становится очень чувствительным при снижении процента сглаживания | 15 | float · min 0 · step 0.5 | bull bear Trading zones Volume difference |
| Show background zonesShow the color background of the current trading zone.\n\nПоказывать цветовой фон текущей торговой зоны. | true | bool | Trading zones |
| Show each setup in zoneShow every signals into trading zone.\n\nПоказывать каждый сигнал внутри торговой зоны. | false | bool | line 28 |
What it calculates
- VWMAbull_vol, Search_range (11)
avg_bull_vol · line 13 - VWMAbear_vol, Search_range (11)
avg_bear_vol · line 14 - SMAavg_bull_vol / volume - 1 - (avg_bear_vol / volume - 1), Search_range (11)
diff_vol · line 15
Signal flow
How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Close Short | bull and up == 1 | On | 36 |
| Close Long | bear and dn == 1 | On | 37 |
| Open Long long | direction != 'SHORT' and bull and up == 1 | On | 38 |
| Open Short short | direction != 'LONG' and bear and dn == 1 | On | 39 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Alerts
| Alert | Call | Message | Line |
|---|---|---|---|
| (no title) | alert | Bullish movement! LONG trading zone | 41 |
| (no title) | alert | Bearish movement! SHORT trading zone | 43 |
Does it repaint?
No
No repainting patterns in the source, and the live replay matched history.
- ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
- ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +92.0% | +102.5% | 45 | 31% | 1.61 | 24.6% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −5.1% | +5.5% | 54 | 33% | 0.93 | 21.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +68.7% | +9.8% | 49 | 33% | 1.25 | 42.6% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +6.5% | +8.4% | 56 | 32% | 1.07 | 23.8% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +20.9% | +16.7% | 45 | 44% | 1.07 | 66.4% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −12.9% | +21.5% | 56 | 32% | 0.88 | 37.7% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +140.1% | +148.3% | 49 | 45% | 2.12 | 18.2% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −21.8% | +17.1% | 46 | 33% | 0.66 | 36.8% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
The trades
By market direction
| At entry, last 90 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 11 | 18% | −$2,882.13 |
| Sideways market | 24 | 38% | $11,134.90 |
| Falling market | 10 | 30% | $954.34 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
37.2%
The 95th percentile of the worst drawdown when the same 45 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 17.5% to 37.2%; the tick is what actually happened, 20.3%. Order luck alone moves it this much.
All 45 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 6 Feb 2024 42,708.70 | 16 Mar 2024 69,499.80 | 39 | $6,262.48 |
| short | 16 Mar 2024 69,499.80 | 31 Mar 2024 69,582.20 | 15 | −$19.85 |
| long | 31 Mar 2024 69,582.20 | 6 Apr 2024 67,820.60 | 6 | −$261.06 |
| short | 6 Apr 2024 67,820.60 | 21 May 2024 71,446.60 | 45 | −$542.86 |
| long | 21 May 2024 71,446.60 | 1 Jun 2024 67,540.00 | 11 | −$554.57 |
| short | 1 Jun 2024 67,540.00 | 6 Jun 2024 71,108.00 | 5 | −$536.49 |
| long | 6 Jun 2024 71,108.00 | 16 Jun 2024 66,228.30 | 10 | −$693.97 |
| short | 16 Jun 2024 66,228.30 | 17 Jul 2024 65,044.00 | 31 | $170.88 |
| long | 17 Jul 2024 65,044.00 | 1 Aug 2024 64,628.00 | 15 | −$71.93 |
| short | 1 Aug 2024 64,628.00 | 17 Aug 2024 58,874.60 | 16 | $882.59 |
| long | 17 Aug 2024 58,874.60 | 4 Sep 2024 57,487.70 | 18 | −$243.47 |
| short | 4 Sep 2024 57,487.70 | 18 Sep 2024 60,314.00 | 14 | −$499.82 |
| long | 18 Sep 2024 60,314.00 | 2 Oct 2024 60,804.90 | 14 | $73.36 |
| short | 2 Oct 2024 60,804.90 | 15 Oct 2024 66,084.00 | 13 | −$876.53 |
| long | 15 Oct 2024 66,084.00 | 4 Dec 2024 95,849.70 | 50 | $4,494.42 |
| short | 4 Dec 2024 95,849.70 | 21 Jan 2025 102,260.00 | 48 | −$677.05 |
| long | 21 Jan 2025 102,260.00 | 15 Feb 2025 97,500.50 | 25 | −$473.25 |
| short | 15 Feb 2025 97,500.50 | 22 Mar 2025 84,088.80 | 35 | $1,368.10 |
| long | 22 Mar 2025 84,088.80 | 31 Mar 2025 82,390.00 | 9 | −$209.94 |
| short | 31 Mar 2025 82,390.00 | 10 Apr 2025 82,615.20 | 10 | −$35.35 |
| long | 10 Apr 2025 82,615.20 | 20 May 2025 105,574.00 | 40 | $2,769.86 |
| short | 20 May 2025 105,574.00 | 23 May 2025 111,696.00 | 3 | −$588.16 |
| long | 23 May 2025 111,696.00 | 3 Jun 2025 105,858.00 | 11 | −$530.48 |
| short | 3 Jun 2025 105,858.00 | 4 Jul 2025 109,585.00 | 31 | −$360.19 |
| long | 4 Jul 2025 109,585.00 | 26 Jul 2025 117,614.00 | 22 | $724.43 |
| short | 26 Jul 2025 117,614.00 | 14 Aug 2025 123,306.00 | 19 | −$492.16 |
| long | 14 Aug 2025 123,306.00 | 25 Aug 2025 113,494.00 | 11 | −$803.49 |
| short | 25 Aug 2025 113,494.00 | 12 Sep 2025 115,483.00 | 18 | −$183.33 |
| long | 12 Sep 2025 115,483.00 | 23 Sep 2025 112,651.00 | 11 | −$253.11 |
| short | 23 Sep 2025 112,651.00 | 4 Oct 2025 122,232.00 | 11 | −$858.86 |
| long | 4 Oct 2025 122,232.00 | 11 Oct 2025 112,774.00 | 7 | −$781.44 |
| short | 11 Oct 2025 112,774.00 | 13 Dec 2025 90,268.40 | 63 | $1,988.47 |
| long | 13 Dec 2025 90,268.40 | 26 Jan 2026 86,670.40 | 44 | −$406.44 |
| short | 26 Jan 2026 86,670.40 | 17 Feb 2026 68,892.40 | 22 | $2,044.03 |
| long | 17 Feb 2026 68,892.40 | 18 Feb 2026 67,503.50 | 1 | −$209.53 |
| short | 18 Feb 2026 67,503.50 | 11 Mar 2026 69,948.60 | 21 | −$370.37 |
| long | 11 Mar 2026 69,948.60 | 28 Mar 2026 66,407.30 | 17 | −$514.08 |
| short | 28 Mar 2026 66,407.30 | 14 Apr 2026 74,418.00 | 17 | −$1,214.78 |
| long | 14 Apr 2026 74,418.00 | 18 May 2026 77,457.70 | 34 | $400.30 |
| short | 18 May 2026 77,457.70 | 7 Jul 2026 64,042.90 | 50 | $1,724.57 |
| long | 7 Jul 2026 64,042.90 | 2 Aug 2026 62,823.70 | 26 | −$198.31 |
| short | 2 Aug 2026 62,823.70 | 20 Aug 2026 69,334.80 | 18 | −$1,044.83 |
| long | 20 Aug 2026 69,334.80 | 11 Sep 2026 76,568.70 | 22 | $1,034.92 |
| short | 11 Sep 2026 76,568.70 | 20 Sep 2026 81,250.00 | 9 | −$619.63 |
| long | 20 Sep 2026 81,250.00 | 3 Oct 2026 84,518.00 | 13 | $394.06 |
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Volume fight strategy this page | — | v5 strategy | +92.0% | 45 | 24.6% |
| Volume Weighted Moving Average by Zeal Terminal | vwma sma | v5 indicator | indicator | ||
| Wave Trend w- VWMA overlay by jadamcraig | vwma sma | v4 strategy | No trades on this market | ||
| VWMA-SMA 3Commas Bot by CrackingCryptocurrency | sma vwma | v5 strategy | −1,774,150,000.0% | 157 | 50,545.9% |
| Smoothed Heikin Ashi Trend on Chart - TraderHalai BACKTEST by TraderHalai | sma vwma | v5 strategy | +1.3% | 113 | 5.6% |
Upgrade and export
Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.
- 4 strategy calls use the when = argument (line 36, 37, 38, 39). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- No v6-only features. v6 is not needed to run this script.
Same 45 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 36: when = bull and up == 1 → if block
- Line 37: when = bear and dn == 1 → if block
- Line 38: when = direction != 'SHORT' and bull and up == 1 → if block
- Line 39: when = direction != 'LONG' and bear and dn == 1 → if block
⋯plot(diff_vol, 'Volume difference', style=plot.style_area, color=avg_bull_vol > avg_bear_vol and vol_flat / avg_bull_vol < 1 - delta / 100 ? color.new(color.green, 0) : avg_bull_vol < avg_bear_vol and vol_flat / avg_bear_vol < 1 - delta / 100 ? color.new(color.red, 0) : color.new(color.gray, 50))-strategy.close('Short', comment='close', when=bull and up == 1)+if bull and up == 1+ strategy.close('Short', comment='close')-strategy.close('Long', comment='close', when=bear and dn == 1)+if bear and dn == 1+ strategy.close('Long', comment='close')-strategy.entry('Long', strategy.long, when=direction != 'SHORT' and bull and up == 1)+if direction != 'SHORT' and bull and up == 1+ strategy.entry('Long', strategy.long)-strategy.entry('Short', strategy.short, when=direction != 'LONG' and bear and dn == 1)+if direction != 'LONG' and bear and dn == 1+ strategy.entry('Short', strategy.short)if bull and up==1⋯Does it run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 45 before, 1 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © Shuttle_Club-//@version=5+//@version=6strategy('Volume fight strategy', default_qty_type=strategy.cash, default_qty_value=10000, currency='USD', commission_value=0.04, calc_on_order_fills=false, calc_on_every_tick=false, initial_capital=10000)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 42 ms | Yes 1,000 bars in 49 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.
Source
Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © Shuttle_Club//@version=5strategy('Volume fight strategy', default_qty_type=strategy.cash, default_qty_value=10000, currency='USD', commission_value=0.04, calc_on_order_fills=false, calc_on_every_tick=false, initial_capital=10000)direction = input.string('ANY', 'Direction', options=['LONG', 'SHORT', 'ANY'], tooltip='Select the direction of trade.\n\nВыберите направление торговли.')ma = input.int(11, 'Search_range', minval=1, tooltip='The range of estimation of the predominance of bullish or bearish volume (quantity bars). The smaller the TF, the higher the range value should be used to filter out false signals.\n\nДиапазон оценки преобладания бычьего или медвежьего объема (количество баров). Чем меньше ТФ, тем выше следует использовать значение диапазона, чтобы отфильтровать ложные сигналы.')delta = input.float(15, 'Smoothing_for_flat,%', step=0.5, minval=0, tooltip='Smoothing to reduce false signals and highlight the flat zone. If you set the percentage to zero, the flat zones will not be highlighted, but there will be much more false signals, since the indicator becomes very sensitive when the smoothing percentage decreases.\n\nСглаживание для уменьшения ложных сигналов и выделения зоны флета. Если выставить процент равным нулю, то зоны флета выделяться не будут, но будет гораздо больше ложных сигналов, так как индикатор становится очень чувствительным при снижении процента сглаживания')bgshow = input.bool(true, 'Show background zones', tooltip='Show the color background of the current trading zone.\n\nПоказывать цветовой фон текущей торговой зоны.')all_signal_show = input.bool(false, 'Show each setup in zone', tooltip='Show every signals into trading zone.\n\nПоказывать каждый сигнал внутри торговой зоны.')///// CALCULATIONbull_vol = open < close ? volume : volume * (high - open) / (high - low) //determine the share of bullish volumebear_vol = open > close ? volume : volume * (open - low) / (high - low) //determine the share of bearish volumeavg_bull_vol = ta.vwma(bull_vol, ma) //determine vwmaavg_bear_vol = ta.vwma(bear_vol, ma)diff_vol = ta.sma(avg_bull_vol / volume - 1 - (avg_bear_vol / volume - 1), ma) //normalize and smooth the valuesvol_flat = math.abs(avg_bull_vol + avg_bear_vol) / 2 //determine average value for calculation flat-filter///// SIGNALSup = int(na), up := nz(up[1])dn = int(na), dn := nz(dn[1])bull = avg_bull_vol > avg_bear_vol and vol_flat / avg_bull_vol < 1 - delta / 100 //determine up zonesbear = avg_bull_vol < avg_bear_vol and vol_flat / avg_bear_vol < 1 - delta / 100 //determine dn zonesif bull up += 1, dn := 0 dnif bear dn += 1, up := 0 upif not bull and not bear and all_signal_show up := 0, dn := 0 dn///// PLOTTINGplotshape(bull and up == 1, 'UP', location=location.bottom, style=shape.triangleup, color=color.new(color.green, 0), size=size.tiny)plotshape(bear and dn == 1, 'DN', location=location.top, style=shape.triangledown, color=color.new(color.red, 0), size=size.tiny)bgcolor(title='Trading zones', color=bgshow and avg_bull_vol > avg_bear_vol and vol_flat / avg_bull_vol < 1 - delta / 100 ? color.new(color.green, 85) : bgshow and avg_bull_vol < avg_bear_vol and vol_flat / avg_bear_vol < 1 - delta / 100 ? color.new(color.red, 85) : na)plot(diff_vol, 'Volume difference', style=plot.style_area, color=avg_bull_vol > avg_bear_vol and vol_flat / avg_bull_vol < 1 - delta / 100 ? color.new(color.green, 0) : avg_bull_vol < avg_bear_vol and vol_flat / avg_bear_vol < 1 - delta / 100 ? color.new(color.red, 0) : color.new(color.gray, 50))strategy.close('Short', comment='close', when=bull and up == 1)strategy.close('Long', comment='close', when=bear and dn == 1)strategy.entry('Long', strategy.long, when=direction != 'SHORT' and bull and up == 1)strategy.entry('Short', strategy.short, when=direction != 'LONG' and bear and dn == 1)if bull and up==1 alert('Bullish movement! LONG trading zone', alert.freq_once_per_bar_close)if bear and dn==1 alert('Bearish movement! SHORT trading zone', alert.freq_once_per_bar_close)