Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

EMA_cumulativeVolume_crossover[Strategy]

A Pine Script v4 strategy built on EMA (close, 50). It has 8 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 20% of equity and pays no commission. 6 settings; defaults include EMA Length 50, cumulative volume Period 100 and Risk % of capital 10.

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 EMA_cumulativeVolume_crossover[Strategy] repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 1 of 1 trades.
How did EMA_cumulativeVolume_crossover[Strategy] do on BTCUSDT 1D with default settings?
+17.50%
From 26 Jan 2024 to 21 Oct 2026, over 6 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can EMA_cumulativeVolume_crossover[Strategy] be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does EMA_cumulativeVolume_crossover[Strategy] use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does EMA_cumulativeVolume_crossover[Strategy] run in Zeal Terminal?
Yes
It compiles in 25 ms and runs 1,000 bars in 57 ms, in the browser.

BTCUSDT · 1D · default settings

  • EMA
  • Cumulate Volumne / VWAP
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (6)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$12,802$20,253Equity from $10,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. Zeal Terminal's engine currently reads an order side written as long = true, long = false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 25, 38) so the engine trades the way the script says.
Net profit
+17.50%
$1,749.80
Buy and hold
+102.5%
same period
Closed trades
6
3 won · 3 lost
Profitable
50.0%
of closed trades
Profit factor
1.34
gross profit ÷ gross loss
Max drawdown
28.87%
−$4,431.33

One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A long 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.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • 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 25, 33, 35, 36, 38, 46, 49, 50. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 17

    transp = on line 17, 18. v5 folds the transparency into the colour with color.new(c, transp).

  • Note

    Uses long =, which v5 renamed line 25

    long = on line 25, 38. v5 writes it as direction = strategy.long or strategy.short.

Upgrade and export

Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.

  • Upgrading to v5 renames sum → math.sum, ema → ta.ema, crossover → ta.crossover, tostring → str.tostring, crossunder → ta.crossunder, abs → math.abs.
  • 8 strategy calls use the when = argument (line 25, 33, 35, 36, 38, 46, 49, 50). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

Same 6 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 13: sum → math.sum
  • Line 14: sum → math.sum
  • Line 16: ema → ta.ema
  • Line 17: transp = 25 → color.new(color.green, 25)
  • Line 18: transp = 25 → color.new(color.orange, 25)
16 more edits
  • Line 25: long = true → direction = strategy.long
  • Line 25: crossover → ta.crossover
  • Line 33: tostring → str.tostring
  • Line 33: crossunder → ta.crossunder
  • Line 35: tostring → str.tostring
  • Line 35: crossunder → ta.crossunder
  • Line 36: tostring → str.tostring
  • Line 38: long = false → direction = strategy.short
  • Line 40: abs → math.abs
  • Line 42: abs → math.abs
  • Line 44: abs → math.abs
  • Line 49: tostring → str.tostring
  • Line 49: abs → math.abs
  • Line 49: crossover → ta.crossover
  • Line 50: tostring → str.tostring
  • Line 50: abs → math.abs
⋯// © mohanee-//@version=4+//@version=5strategy("EMA_cumulativeVolume_crossover[Strategy]", overlay=true, pyramiding=1, default_qty_type=strategy.percent_of_equity,  default_qty_value=20, initial_capital=10000)⋯avgPriceVolume = avgPrice * volume-cumulPriceVolume = sum(avgPriceVolume, cumulativePeriod)+cumulPriceVolume = math.sum(avgPriceVolume, cumulativePeriod)-cumulVolume = sum(volume, cumulativePeriod)+cumulVolume = math.sum(volume, cumulativePeriod)vwapValue = cumulPriceVolume / cumulVolume-emaVal=ema(close, emaLength)+emaVal=ta.ema(close, emaLength)-plot(emaVal, title="EMA", color=color.green,  transp=25)+plot(emaVal, title="EMA", color=color.new(color.green, 25))-plot(vwapValue, title="Cumulate Volumne / VWAP", color=color.orange,  linewidth=2, transp=25)+plot(vwapValue, title="Cumulate Volumne / VWAP", color=color.new(color.orange, 25),  linewidth=2)bgcolor(emaVal>vwapValue?color.blue:color.purple)    ⋯qty1:= (qty1 * close >= strategy.equity ) ? (strategy.equity / close) : qty1-strategy.entry(id="LE",comment="LE", long=true, qty=qty1, when=crossover(emaVal, vwapValue)  and (tradeDirection=="LONG") )    //emaVal>vwapValue and crossover(close , emaVal)+strategy.entry(id="LE",comment="LE", direction = strategy.long, qty=qty1, when=ta.crossover(emaVal, vwapValue)  and (tradeDirection=="LONG") )    //emaVal>vwapValue and crossover(close , emaVal)//stoploss⋯if(takePartialProfits==true)-    strategy.close(id="LE", comment="Partial"+tostring(close-strategy.position_avg_price, "###.##") , qty=strategy.position_size/3 , when = (tradeDirection=="LONG" ) and close>takeProfit and crossunder(close, emaVal) )    //close<close[1] and close[1]<close[2] and close[2]<close[3])+    strategy.close(id="LE", comment="Partial"+str.tostring(close-strategy.position_avg_price, "###.##") , qty=strategy.position_size/3 , when = (tradeDirection=="LONG" ) and close>takeProfit and ta.crossunder(close, emaVal) )    //close<close[1] and close[1]<close[2] and close[2]<close[3])    -strategy.close(id="LE" , comment="LE Exit Points="+tostring(close-strategy.position_avg_price, "###.##"), when=crossunder(emaVal, vwapValue) and (tradeDirection=="LONG") )+strategy.close(id="LE" , comment="LE Exit Points="+str.tostring(close-strategy.position_avg_price, "###.##"), when=ta.crossunder(emaVal, vwapValue) and (tradeDirection=="LONG") )-strategy.close(id="LE" , comment="SL Exit Loss="+tostring(close-strategy.position_avg_price, "###.##"), when= close < stopLossVal   and (tradeDirection=="LONG") )+strategy.close(id="LE" , comment="SL Exit Loss="+str.tostring(close-strategy.position_avg_price, "###.##"), when= close < stopLossVal   and (tradeDirection=="LONG") )//for short  you dont have to wait crossodown of ema, falling is speed , so just check if close crossing down vwapVal-strategy.entry(id="SE",comment="SE", long=false, qty=qty1, when=(close<vwapValue and close<open  and close[1] < vwapValue  and close[1]<open[1] and close<close[1])  and emaVal>=vwapValue and (tradeDirection=="SHORT") )    //emaVal>vwapValue and crossover(close , emaVal)+strategy.entry(id="SE",comment="SE", direction = strategy.short, qty=qty1, when=(close<vwapValue and close<open  and close[1] < vwapValue  and close[1]<open[1] and close<close[1])  and emaVal>=vwapValue and (tradeDirection=="SHORT") )    //emaVal>vwapValue and crossover(close , emaVal)//stoploss-stopLossValUpside=  abs(strategy.position_size)>=1 and tradeDirection=="SHORT" ?  (strategy.position_avg_price * (1+(stopLoss*0.01) )) : 0.00+stopLossValUpside=  math.abs(strategy.position_size)>=1 and tradeDirection=="SHORT" ?  (strategy.position_avg_price * (1+(stopLoss*0.01) )) : 0.00//draw initil stop loss-plot(abs(strategy.position_size)>=1 and tradeDirection=="SHORT" ? stopLossValUpside : na, color = color.purple , style=plot.style_linebr,  linewidth = 2, title = "stop loss")+plot(math.abs(strategy.position_size)>=1 and tradeDirection=="SHORT" ? stopLossValUpside : na, color = color.purple , style=plot.style_linebr,  linewidth = 2, title = "stop loss")//partial exits-shortTakeProfit=  abs(strategy.position_size)>=1 and tradeDirection=="SHORT" ?  (strategy.position_avg_price * (1-(stopLoss*0.01) )) : 0.00+shortTakeProfit=  math.abs(strategy.position_size)>=1 and tradeDirection=="SHORT" ?  (strategy.position_avg_price * (1-(stopLoss*0.01) )) : 0.00if(takePartialProfits==true)⋯//strategy.close(id="SE" , comment="SE Exit Points="+tostring(close-strategy.position_avg_price, "###.##"), when=crossover(emaVal, vwapValue) and (tradeDirection=="SHORT") )-strategy.close(id="SE" , comment="SE Exit Points="+tostring(close-strategy.position_avg_price, "###.##"), when= abs(strategy.position_size)>=1 and ( (emaVal<vwapValue and close>vwapValue and open>vwapValue and close>open )   or (crossover(emaVal,vwapValue))  ) and (tradeDirection=="SHORT") )+strategy.close(id="SE" , comment="SE Exit Points="+str.tostring(close-strategy.position_avg_price, "###.##"), when= math.abs(strategy.position_size)>=1 and ( (emaVal<vwapValue and close>vwapValue and open>vwapValue and close>open )   or (ta.crossover(emaVal,vwapValue))  ) and (tradeDirection=="SHORT") )-strategy.close(id="SE" , comment="SL Exit Loss="+tostring(close-strategy.position_avg_price, "###.##"), when= abs(strategy.position_size)>=1 and  close > stopLossValUpside   and (tradeDirection=="SHORT"   ) )+strategy.close(id="SE" , comment="SL Exit Loss="+str.tostring(close-strategy.position_avg_price, "###.##"), when= math.abs(strategy.position_size)>=1 and  close > stopLossValUpside   and (tradeDirection=="SHORT"   ) )

Clean v5

VerifiedDownload the v5 script

Same 6 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 5: input() → input.int()
  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 8: input() → input.int()
  • Line 9: input() → input.bool()
  • Line 10: input() → input.string()
8 more edits
  • Line 25: when = ta.crossover(emaVal, vwapValue) and (tradeDirection=="LONG") → if block
  • Line 33: when = (tradeDirection=="LONG" ) and close>takeProfit and ta.crossunder(close, emaVal) → if block
  • Line 35: when = ta.crossunder(emaVal, vwapValue) and (tradeDirection=="LONG") → if block
  • Line 36: when = close < stopLossVal and (tradeDirection=="LONG") → if block
  • Line 38: when = (close<vwapValue and close<open and close[1] < vwapValue and close[1]<open[1] and close<close[1]) and emaVal>=vwapValue and (tradeDirection=="SHORT") → if block
  • Line 46: when = (tradeDirection=="SHORT" ) and close<shortTakeProfit → if block
  • Line 49: when = math.abs(strategy.position_size)>=1 and ( (emaVal<vwapValue and close>vwapValue and open>vwapValue and close>open ) or (ta.crossover(emaVal,vwapValue)) ) and (tradeDirection=="SHORT") → if block
  • Line 50: when = math.abs(strategy.position_size)>=1 and close > stopLossValUpside and (tradeDirection=="SHORT" ) → if block
⋯strategy("EMA_cumulativeVolume_crossover[Strategy]", overlay=true, pyramiding=1, default_qty_type=strategy.percent_of_equity,  default_qty_value=20, initial_capital=10000)-emaLength= input(50, title="EMA Length", minval=1, maxval=200)+emaLength= input.int(50, title="EMA Length", minval=1, maxval=200)-cumulativePeriod = input(100,  title="cumulative volume Period", minval=1, maxval=200)+cumulativePeriod = input.int(100,  title="cumulative volume Period", minval=1, maxval=200)-riskCapital = input(title="Risk % of capital", defval=10, minval=1)+riskCapital = input.int(title="Risk % of capital", defval=10, minval=1)-stopLoss=input(8,title="Stop Loss",minval=1)+stopLoss=input.int(8,title="Stop Loss",minval=1)-takePartialProfits=input(false, title="take partial profits  (percentage same as stop loss)")+takePartialProfits=input.bool(false, title="take partial profits  (percentage same as stop loss)")-tradeDirection=input(title="Trade Direction", defval="LONG", options=["LONG", "SHORT"])+tradeDirection=input.string(title="Trade Direction", defval="LONG", options=["LONG", "SHORT"])avgPrice = (high + low + close) / 3⋯qty1:= (qty1 * close >= strategy.equity ) ? (strategy.equity / close) : qty1-strategy.entry(id="LE",comment="LE", direction = strategy.long, qty=qty1, when=ta.crossover(emaVal, vwapValue)  and (tradeDirection=="LONG") )    //emaVal>vwapValue and crossover(close , emaVal)+if ta.crossover(emaVal, vwapValue)  and (tradeDirection=="LONG")+    strategy.entry(id="LE",comment="LE", direction = strategy.long, qty=qty1 )    //emaVal>vwapValue and crossover(close , emaVal)//stoploss⋯if(takePartialProfits==true)-    strategy.close(id="LE", comment="Partial"+str.tostring(close-strategy.position_avg_price, "###.##") , qty=strategy.position_size/3 , when = (tradeDirection=="LONG" ) and close>takeProfit and ta.crossunder(close, emaVal) )    //close<close[1] and close[1]<close[2] and close[2]<close[3])+    if (tradeDirection=="LONG" ) and close>takeProfit and ta.crossunder(close, emaVal)+        strategy.close(id="LE", comment="Partial"+str.tostring(close-strategy.position_avg_price, "###.##") , qty=strategy.position_size/3  )    //close<close[1] and close[1]<close[2] and close[2]<close[3])    -strategy.close(id="LE" , comment="LE Exit Points="+str.tostring(close-strategy.position_avg_price, "###.##"), when=ta.crossunder(emaVal, vwapValue) and (tradeDirection=="LONG") )+if ta.crossunder(emaVal, vwapValue) and (tradeDirection=="LONG")+    strategy.close(id="LE" , comment="LE Exit Points="+str.tostring(close-strategy.position_avg_price, "###.##") )-strategy.close(id="LE" , comment="SL Exit Loss="+str.tostring(close-strategy.position_avg_price, "###.##"), when= close < stopLossVal   and (tradeDirection=="LONG") )+if close < stopLossVal   and (tradeDirection=="LONG")+    strategy.close(id="LE" , comment="SL Exit Loss="+str.tostring(close-strategy.position_avg_price, "###.##") )//for short  you dont have to wait crossodown of ema, falling is speed , so just check if close crossing down vwapVal-strategy.entry(id="SE",comment="SE", direction = strategy.short, qty=qty1, when=(close<vwapValue and close<open  and close[1] < vwapValue  and close[1]<open[1] and close<close[1])  and emaVal>=vwapValue and (tradeDirection=="SHORT") )    //emaVal>vwapValue and crossover(close , emaVal)+if (close<vwapValue and close<open  and close[1] < vwapValue  and close[1]<open[1] and close<close[1])  and emaVal>=vwapValue and (tradeDirection=="SHORT")+    strategy.entry(id="SE",comment="SE", direction = strategy.short, qty=qty1 )    //emaVal>vwapValue and crossover(close , emaVal)//stoploss⋯if(takePartialProfits==true)-    strategy.close(id="SE", comment="Partial" , qty=strategy.position_size/3 , when = (tradeDirection=="SHORT"   ) and  close<shortTakeProfit )  //close<takeProfit and (emaVal - close)>8 )+    if (tradeDirection=="SHORT"   ) and  close<shortTakeProfit+        strategy.close(id="SE", comment="Partial" , qty=strategy.position_size/3  )  //close<takeProfit and (emaVal - close)>8 )  //strategy.close(id="SE" , comment="SE Exit Points="+tostring(close-strategy.position_avg_price, "###.##"), when=crossover(emaVal, vwapValue) and (tradeDirection=="SHORT") )-strategy.close(id="SE" , comment="SE Exit Points="+str.tostring(close-strategy.position_avg_price, "###.##"), when= math.abs(strategy.position_size)>=1 and ( (emaVal<vwapValue and close>vwapValue and open>vwapValue and close>open )   or (ta.crossover(emaVal,vwapValue))  ) and (tradeDirection=="SHORT") )+if math.abs(strategy.position_size)>=1 and ( (emaVal<vwapValue and close>vwapValue and open>vwapValue and close>open )   or (ta.crossover(emaVal,vwapValue))  ) and (tradeDirection=="SHORT")+    strategy.close(id="SE" , comment="SE Exit Points="+str.tostring(close-strategy.position_avg_price, "###.##") )-strategy.close(id="SE" , comment="SL Exit Loss="+str.tostring(close-strategy.position_avg_price, "###.##"), when= math.abs(strategy.position_size)>=1 and  close > stopLossValUpside   and (tradeDirection=="SHORT"   ) )+if math.abs(strategy.position_size)>=1 and  close > stopLossValUpside   and (tradeDirection=="SHORT"   )+    strategy.close(id="SE" , comment="SL Exit Loss="+str.tostring(close-strategy.position_avg_price, "###.##") )

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: 6 before, 4 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.

⋯// © mohanee-//@version=5+//@version=6strategy("EMA_cumulativeVolume_crossover[Strategy]", overlay=true, pyramiding=1, default_qty_type=strategy.percent_of_equity,  default_qty_value=20, initial_capital=10000)⋯

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
EMA Length50int · min 1 · max 200emaVal
cumulative volume Period100int · min 1 · max 200cumulPriceVolume cumulVolume
Risk % of capital10int · min 1qty1
Stop Loss8int · min 1qty1 stopLossVal takeProfit stopLossValUpside shortTakeProfit
take partial profits (percentage same as stop loss)falseboolclose LE close SE line 32 line 45
Trade DirectionLONGstring · options ["LONG", "SHORT"]stopLossValUpside shortTakeProfit entry LE close LE entry SE stop loss close SE

What it calculates

  • EMA (ema, ta.ema in v5)close, EMA Length (50)emaVal · line 16

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.

closecloseprice dataemaLengthEMA Lengthsetting · 50lowlowprice datahighhighprice datavolumevolumeprice datacumulativePeriodcumulative volume Periodsetting · 100riskCapitalRisk % of capitalsetting · 10stopLossStop Losssetting · 8tradeDirectionTrade Directionsetting · LONGopenopenprice dataemaValEMA→ emaValavgPriceavgPricevalueavgPriceVolumeavgPriceVolumevaluecumulPriceVolumecumulPriceVolumevaluecumulVolumecumulVolumevaluevwapValuevwapValuevalueqty1qty1valuestopLossValstopLossValvaluetakeProfittakeProfitvaluestopLossValUpside, shortTakeProfitstopLossValUpside · sho…2 valuesentry:LEOpen LEstrategy.entryclose:LEClose LEstrategy.closeentry:SEOpen SEstrategy.entryclose:SEClose SEstrategy.closeplot:17EMAplotplot:18Cumulate Volumne / VWAPplotbgcolor:19bgcolorbgcolorplot:29stop lossplotplot:42stop lossplot

Order rules

OrderFires whenBy defaultLine
Open LE longcrossover(emaVal, vwapValue) and (tradeDirection=="LONG")On25
Close LE(tradeDirection=="LONG" ) and close>takeProfit and crossunder(close, emaVal)On33
Close LEcrossunder(emaVal, vwapValue) and (tradeDirection=="LONG")On35
Close LEclose < stopLossVal and (tradeDirection=="LONG")On36
Open SE short(close<vwapValue and close<open and close[1] < vwapValue and close[1]<open[1] and close<close[1]) and emaVal>=vwapValue and (tradeDirection=="SHORT")On38
Close SE(tradeDirection=="SHORT" ) and close<shortTakeProfitOn46
Close SEabs(strategy.position_size)>=1 and ( (emaVal<vwapValue and close>vwapValue and open>vwapValue and close>open ) or (crossover(emaVal,vwapValue)) ) and (tradeDirection=="SHORT")On49
Close SEabs(strategy.position_size)>=1 and close > stopLossValUpside and (tradeDirection=="SHORT" )On50

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

1/1trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+17.5%+102.5%650%1.3428.9%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+2.0%+5.5%667%1.1711.8%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−13.6%+9.8%425%0.4918.1%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+9.7%+8.4%956%1.5811.4%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−28.5%+16.7%617%0.2429.6%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+25.0%+21.5%475%3.8711.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+41.7%+148.3%367%3.6514.7%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+18.0%+17.1%560%3.746.6%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 barsTradesWonP&L
Rising market0—$0.00
Sideways market650%$1,749.80
Falling market0—$0.00

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

34.8%

The 95th percentile of the worst drawdown when the same 6 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 17.8% to 34.8%; the tick is what actually happened, 23.5%. Order luck alone moves it this much.

0%40%
All 6 trades
SideEntryExitBarsP&L
long29 Jul 2024 68,249.905 Aug 2024 58,161.007−$1,478.23
long6 Aug 2024 54,018.807 Aug 2024 56,022.001$316.01
long25 Sep 2024 64,262.7023 Feb 2025 96,551.00151$4,440.48
long5 May 2025 94,277.6026 Sep 2025 108,994.00144$2,072.76
long8 Oct 2025 121,333.0015 Oct 2025 113,028.007−$1,050.73
long25 Apr 2026 77,437.1012 Jun 2026 63,626.0048−$2,550.50

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
EMA_cumulativeVolume_crossover[Strategy] this page—v4 strategy+17.5%628.9%
EMA Slope AyE by fajardoarelysemav4 strategyNo trades on this market
ROoT by realisticDove62527emav5 strategy−4.7%2259.4%
sachin5986 by mohitesachin78emav4 strategy+32.1%3517.6%
sonu1997 by Sonu1997emav4 strategy+960.7%21,103.8%
Moving Average Crossover by Muh4mm4demav4 strategy+19,990.1%301,274.2%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 25 msWith a workaround 1,000 bars in 57 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as long = true, long = false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 25, 38) so the engine trades the way the script says.

“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. PineTS runs Pine Script v5 and v6 only.

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/// © mohanee//@version=4strategy("EMA_cumulativeVolume_crossover[Strategy]", overlay=true, pyramiding=1, default_qty_type=strategy.percent_of_equity,  default_qty_value=20, initial_capital=10000)emaLength= input(50, title="EMA Length", minval=1, maxval=200)cumulativePeriod = input(100,  title="cumulative volume Period", minval=1, maxval=200)riskCapital = input(title="Risk % of capital", defval=10, minval=1)stopLoss=input(8,title="Stop Loss",minval=1)takePartialProfits=input(false, title="take partial profits  (percentage same as stop loss)")tradeDirection=input(title="Trade Direction", defval="LONG", options=["LONG", "SHORT"])avgPrice = (high + low + close) / 3avgPriceVolume = avgPrice * volumecumulPriceVolume = sum(avgPriceVolume, cumulativePeriod)cumulVolume = sum(volume, cumulativePeriod)vwapValue = cumulPriceVolume / cumulVolumeemaVal=ema(close, emaLength)plot(emaVal, title="EMA", color=color.green,  transp=25)plot(vwapValue, title="Cumulate Volumne / VWAP", color=color.orange,  linewidth=2, transp=25)bgcolor(emaVal>vwapValue?color.blue:color.purple)    //Entry--//Echeck how many units can be purchased based on risk manage ment and stop lossqty1 = (strategy.equity  * riskCapital / 100 ) /  (close*stopLoss/100)  //check if cash is sufficient  to buy qty1  , if capital not available use the available capital onlyqty1:= (qty1 * close >= strategy.equity ) ? (strategy.equity / close) : qty1strategy.entry(id="LE",comment="LE", long=true, qty=qty1, when=crossover(emaVal, vwapValue)  and (tradeDirection=="LONG") )    //emaVal>vwapValue and crossover(close , emaVal)//stoplossstopLossVal=  strategy.position_size>=1 ?  (strategy.position_avg_price * (1-(stopLoss*0.01) )) : 0.00//draw initil stop lossplot(strategy.position_size>=1 ? stopLossVal : na, color = color.purple , style=plot.style_linebr,  linewidth = 2, title = "stop loss")//partial exitstakeProfit=  strategy.position_size>=1 ?  (strategy.position_avg_price * (1+(stopLoss*0.01) )) : ( close[1] * 2 )if(takePartialProfits==true)    strategy.close(id="LE", comment="Partial"+tostring(close-strategy.position_avg_price, "###.##") , qty=strategy.position_size/3 , when = (tradeDirection=="LONG" ) and close>takeProfit and crossunder(close, emaVal) )    //close<close[1] and close[1]<close[2] and close[2]<close[3])    strategy.close(id="LE" , comment="LE Exit Points="+tostring(close-strategy.position_avg_price, "###.##"), when=crossunder(emaVal, vwapValue) and (tradeDirection=="LONG") )strategy.close(id="LE" , comment="SL Exit Loss="+tostring(close-strategy.position_avg_price, "###.##"), when= close < stopLossVal   and (tradeDirection=="LONG") )//for short  you dont have to wait crossodown of ema, falling is speed , so just check if close crossing down vwapValstrategy.entry(id="SE",comment="SE", long=false, qty=qty1, when=(close<vwapValue and close<open  and close[1] < vwapValue  and close[1]<open[1] and close<close[1])  and emaVal>=vwapValue and (tradeDirection=="SHORT") )    //emaVal>vwapValue and crossover(close , emaVal)//stoplossstopLossValUpside=  abs(strategy.position_size)>=1 and tradeDirection=="SHORT" ?  (strategy.position_avg_price * (1+(stopLoss*0.01) )) : 0.00//draw initil stop lossplot(abs(strategy.position_size)>=1 and tradeDirection=="SHORT" ? stopLossValUpside : na, color = color.purple , style=plot.style_linebr,  linewidth = 2, title = "stop loss")//partial exitsshortTakeProfit=  abs(strategy.position_size)>=1 and tradeDirection=="SHORT" ?  (strategy.position_avg_price * (1-(stopLoss*0.01) )) : 0.00if(takePartialProfits==true)    strategy.close(id="SE", comment="Partial" , qty=strategy.position_size/3 , when = (tradeDirection=="SHORT"   ) and  close<shortTakeProfit )  //close<takeProfit and (emaVal - close)>8 )  //strategy.close(id="SE" , comment="SE Exit Points="+tostring(close-strategy.position_avg_price, "###.##"), when=crossover(emaVal, vwapValue) and (tradeDirection=="SHORT") )strategy.close(id="SE" , comment="SE Exit Points="+tostring(close-strategy.position_avg_price, "###.##"), when= abs(strategy.position_size)>=1 and ( (emaVal<vwapValue and close>vwapValue and open>vwapValue and close>open )   or (crossover(emaVal,vwapValue))  ) and (tradeDirection=="SHORT") )strategy.close(id="SE" , comment="SL Exit Loss="+tostring(close-strategy.position_avg_price, "###.##"), when= abs(strategy.position_size)>=1 and  close > stopLossValUpside   and (tradeDirection=="SHORT"   ) )