Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

EMA_cumulativeVolume_crossover[Strategy V2]

A Pine Script v4 strategy built on EMA (close, 25) and RSI (close, 5). It has 8 order rules, 3 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 25, 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 V2] 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 V2] do on BTCUSDT 1D with default settings?
−4.06%
From 26 Jan 2024 to 21 Oct 2026, over 4 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can EMA_cumulativeVolume_crossover[Strategy V2] 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 V2] use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does EMA_cumulativeVolume_crossover[Strategy V2] run in Zeal Terminal?
Yes
It compiles in 20 ms and runs 1,000 bars in 86 ms, in the browser.

BTCUSDT · 1D · default settings

  • EMA
  • emaVwapValue
  • emaVwapValue
  • emaCumValueHistory
  • 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$10,543$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 36, 39, 56) so the engine trades the way the script says.
Net profit
−4.06%
−$406.40
Buy and hold
+102.5%
same period
Closed trades
4
2 won · 2 lost
Profitable
50.0%
of closed trades
Profit factor
0.90
gross profit ÷ gross loss
Max drawdown
23.82%
−$2,914.12

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 36, 39, 50, 53, 54, 56, 64, 69. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 22

    transp = on line 22, 25, 26, 27, 28. v5 folds the transparency into the colour with color.new(c, transp).

  • Note

    Uses long =, which v5 renamed line 36

    long = on line 36, 39, 56. 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, rsi → ta.rsi, crossover → ta.crossover, tostring → str.tostring, crossunder → ta.crossunder, abs → math.abs.
  • 8 strategy calls use the when = argument (line 36, 39, 50, 53, 54, 56, 64, 69). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

Same 4 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: ema → ta.ema
  • Line 18: ema → ta.ema
25 more edits
  • Line 19: ema → ta.ema
  • Line 21: rsi → ta.rsi
  • Line 22: transp = 25 → color.new(color.green, 25)
  • Line 25: transp = 35 → color.new(color.purple, 35)
  • Line 26: transp = 25 → color.new(color.yellow, 25)
  • Line 27: transp = 35 → color.new(emaVal>emaCumValue1 ? color.lime : color.red, 35)
  • Line 28: transp = 25 → color.new(color.black, 25)
  • Line 36: long = true → direction = strategy.long
  • Line 36: crossover → ta.crossover
  • Line 38: crossover → ta.crossover
  • Line 39: long = true → direction = strategy.long
  • Line 40: crossover → ta.crossover
  • Line 50: tostring → str.tostring
  • Line 50: crossunder → ta.crossunder
  • Line 53: tostring → str.tostring
  • Line 53: crossunder → ta.crossunder
  • Line 54: tostring → str.tostring
  • Line 56: long = false → direction = strategy.short
  • Line 56: crossunder → ta.crossunder
  • Line 58: abs → math.abs
  • Line 62: abs → math.abs
  • Line 64: crossover → ta.crossover
  • Line 69: tostring → str.tostring
  • Line 69: abs → math.abs
  • Line 69: crossover → ta.crossover
⋯// © mohanee-//@version=4+//@version=5strategy("EMA_cumulativeVolume_crossover[Strategy]", overlay=true, pyramiding=5, 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)cumValue = cumulPriceVolume / cumulVolume-emaVal=ema(close, emaLength)+emaVal=ta.ema(close, emaLength)-emaCumValue1=ema(cumValue, emaLength)+emaCumValue1=ta.ema(cumValue, emaLength)-emaCumValue2=ema(cumValue, emaLength*2)+emaCumValue2=ta.ema(cumValue, emaLength*2)-emaCumValueHistory=ema(cumValue[emaLength], emaLength)+emaCumValueHistory=ta.ema(cumValue[emaLength], emaLength)//vwapVal1=vwap(hlc3)-rsiVal=rsi(close,5)+rsiVal=ta.rsi(close,5)-plotEma=plot(emaVal, title="EMA", color=color.green,  transp=25)+plotEma=plot(emaVal, title="EMA", color=color.new(color.green, 25))//plot(vwapValue, title="Cumulate Volumne", color=color.orange,  linewidth=2, transp=25)//plot(vwapVal1, title="vwapVal1", color=color.purple,  linewidth=1, transp=25)-plotCum=plot(emaCumValue1, title="emaVwapValue", color=color.purple,  linewidth=2, transp=35)+plotCum=plot(emaCumValue1, title="emaVwapValue", color=color.new(color.purple, 35),  linewidth=2)-plot(emaCumValue2, title="emaVwapValue", color=color.yellow,  linewidth=3, transp=25)+plot(emaCumValue2, title="emaVwapValue", color=color.new(color.yellow, 25),  linewidth=3)-fill(plotEma,plotCum, color=emaVal>emaCumValue1 ? color.lime : color.red, transp=35, title="ema and cum area")+fill(plotEma,plotCum, color=color.new(emaVal>emaCumValue1 ? color.lime : color.red, 35), title="ema and cum area")-plot(emaCumValueHistory, title="emaCumValueHistory", color=color.black,  linewidth=2, transp=25)+plot(emaCumValueHistory, title="emaCumValueHistory", color=color.new(color.black, 25),  linewidth=2)//bgcolor(emaVal>vwapValue?color.blue:color.purple)    ⋯//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", long=true, qty=qty1, when=strategy.position_size==0 and crossover(emaVal, emaCumValue1)  and (tradeDirection=="LONG") )    //emaVal>vwapValue and crossover(close , emaVal)+strategy.entry(id="LE",comment="LE", direction = strategy.long, qty=qty1, when=strategy.position_size==0 and ta.crossover(emaVal, emaCumValue1)  and (tradeDirection=="LONG") )    //emaVal>vwapValue and crossover(close , emaVal)//re-entry-rentryCondition1=strategy.position_size>1 and emaVal > emaCumValue1 and emaCumValue1>emaCumValue2 and crossover(close, emaCumValue2) and close>open and  (tradeDirection=="LONG")+rentryCondition1=strategy.position_size>1 and emaVal > emaCumValue1 and emaCumValue1>emaCumValue2 and ta.crossover(close, emaCumValue2) and close>open and  (tradeDirection=="LONG")-strategy.entry(id="LE",comment="LE RE", long=true, qty=qty1, when=rentryCondition1 )+strategy.entry(id="LE",comment="LE RE", direction = strategy.long, qty=qty1, when=rentryCondition1 )-rentryCondition2=strategy.position_size>1 and emaVal > emaCumValue1 and emaCumValue1>emaCumValueHistory and crossover(close, emaCumValueHistory) and close>open and  (tradeDirection=="LONG")+rentryCondition2=strategy.position_size>1 and emaVal > emaCumValue1 and emaCumValue1>emaCumValueHistory and ta.crossover(close, emaCumValueHistory) and close>open and  (tradeDirection=="LONG")//strategy.entry(id="LE",comment="LE RE", long=true, qty=qty1, when=rentryCondition2 )    ⋯    //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="PExit Points=>"+tostring(close-strategy.position_avg_price, "###.##") , qty=strategy.position_size/3 , when = (tradeDirection=="LONG" ) and  takePartialProfits == true and close>=takeProfit and crossunder(rsiVal,90) )+strategy.close(id="LE", comment="PExit Points=>"+str.tostring(close-strategy.position_avg_price, "###.##") , qty=strategy.position_size/3 , when = (tradeDirection=="LONG" ) and  takePartialProfits == true and close>=takeProfit and ta.crossunder(rsiVal,90) )profitVal=    strategy.position_size>=1 ?  (strategy.position_avg_price * (1+(1*0.01) )) : ( close[1] * 2 )//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="Exit Points=>"+tostring(close-strategy.position_avg_price, "###.##"), when=  crossunder(emaVal, emaCumValue1) and (tradeDirection=="LONG") )+strategy.close(id="LE" , comment="Exit Points=>"+str.tostring(close-strategy.position_avg_price, "###.##"), when=  ta.crossunder(emaVal, emaCumValue1) 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=crossunder(emaVal, emaCumValue1) and (tradeDirection=="SHORT") )    //emaVal>vwapValue and crossover(close , emaVal)+strategy.entry(id="SE",comment="SE", direction = strategy.short, qty=qty1, when=ta.crossunder(emaVal, emaCumValue1) 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⋯//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="Partial" , qty=strategy.position_size/3 , when = (tradeDirection=="SHORT"   ) and  crossover(rsiVal,15) )  //close<takeProfit and (emaVal - close)>8 )+    strategy.close(id="SE", comment="Partial" , qty=strategy.position_size/3 , when = (tradeDirection=="SHORT"   ) and  ta.crossover(rsiVal,15) )  //close<takeProfit and (emaVal - close)>8 )  ⋯//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="+tostring(close-strategy.position_avg_price, "###.##"), when= abs(strategy.position_size)>=1 and  crossover(emaVal, emaCumValue1)   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  ta.crossover(emaVal, emaCumValue1)   and (tradeDirection=="SHORT"   ) )

Clean v5

VerifiedDownload the v5 script

Same 4 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 36: when = strategy.position_size==0 and ta.crossover(emaVal, emaCumValue1) and (tradeDirection=="LONG") → if block
  • Line 39: when = rentryCondition1 → if block
  • Line 50: when = (tradeDirection=="LONG" ) and takePartialProfits == true and close>=takeProfit and ta.crossunder(rsiVal,90) → if block
  • Line 53: when = ta.crossunder(emaVal, emaCumValue1) and (tradeDirection=="LONG") → if block
  • Line 54: when = close < stopLossVal and (tradeDirection=="LONG") → if block
  • Line 56: when = ta.crossunder(emaVal, emaCumValue1) and (tradeDirection=="SHORT") → if block
  • Line 64: when = (tradeDirection=="SHORT" ) and ta.crossover(rsiVal,15) → if block
  • Line 69: when = math.abs(strategy.position_size)>=1 and ta.crossover(emaVal, emaCumValue1) and (tradeDirection=="SHORT" ) → if block
⋯strategy("EMA_cumulativeVolume_crossover[Strategy]", overlay=true, pyramiding=5, default_qty_type=strategy.percent_of_equity,  default_qty_value=20, initial_capital=10000)-emaLength= input(25, title="EMA Length", minval=1, maxval=200)+emaLength= input.int(25, 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(true, title="take partial profits  (percentage same as stop loss)")+takePartialProfits=input.bool(true, 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⋯//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=strategy.position_size==0 and ta.crossover(emaVal, emaCumValue1)  and (tradeDirection=="LONG") )    //emaVal>vwapValue and crossover(close , emaVal)+if strategy.position_size==0 and ta.crossover(emaVal, emaCumValue1)  and (tradeDirection=="LONG")+    strategy.entry(id="LE",comment="LE", direction = strategy.long, qty=qty1 )    //emaVal>vwapValue and crossover(close , emaVal)//re-entryrentryCondition1=strategy.position_size>1 and emaVal > emaCumValue1 and emaCumValue1>emaCumValue2 and ta.crossover(close, emaCumValue2) and close>open and  (tradeDirection=="LONG")-strategy.entry(id="LE",comment="LE RE", direction = strategy.long, qty=qty1, when=rentryCondition1 )+if rentryCondition1+    strategy.entry(id="LE",comment="LE RE", direction = strategy.long, qty=qty1 )rentryCondition2=strategy.position_size>1 and emaVal > emaCumValue1 and emaCumValue1>emaCumValueHistory and ta.crossover(close, emaCumValueHistory) and close>open and  (tradeDirection=="LONG")⋯    //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="PExit Points=>"+str.tostring(close-strategy.position_avg_price, "###.##") , qty=strategy.position_size/3 , when = (tradeDirection=="LONG" ) and  takePartialProfits == true and close>=takeProfit and ta.crossunder(rsiVal,90) )+if (tradeDirection=="LONG" ) and  takePartialProfits == true and close>=takeProfit and ta.crossunder(rsiVal,90)+    strategy.close(id="LE", comment="PExit Points=>"+str.tostring(close-strategy.position_avg_price, "###.##") , qty=strategy.position_size/3  )profitVal=    strategy.position_size>=1 ?  (strategy.position_avg_price * (1+(1*0.01) )) : ( close[1] * 2 )//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="Exit Points=>"+str.tostring(close-strategy.position_avg_price, "###.##"), when=  ta.crossunder(emaVal, emaCumValue1) and (tradeDirection=="LONG") )+if ta.crossunder(emaVal, emaCumValue1) and (tradeDirection=="LONG")+    strategy.close(id="LE" , comment="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=ta.crossunder(emaVal, emaCumValue1) and (tradeDirection=="SHORT") )    //emaVal>vwapValue and crossover(close , emaVal)+if ta.crossunder(emaVal, emaCumValue1) 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  ta.crossover(rsiVal,15) )  //close<takeProfit and (emaVal - close)>8 )+    if (tradeDirection=="SHORT"   ) and  ta.crossover(rsiVal,15)+        strategy.close(id="SE", comment="Partial" , qty=strategy.position_size/3  )  //close<takeProfit and (emaVal - close)>8 )  ⋯//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  ta.crossover(emaVal, emaCumValue1)   and (tradeDirection=="SHORT"   ) )+if math.abs(strategy.position_size)>=1 and  ta.crossover(emaVal, emaCumValue1)   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?

Yes

Same 4 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

⋯// © mohanee-//@version=5+//@version=6strategy("EMA_cumulativeVolume_crossover[Strategy]", overlay=true, pyramiding=5, 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 Length25int · min 1 · max 200emaVal emaCumValue1 emaCumValue2 emaCumValueHistory
cumulative volume Period100int · min 1 · max 200cumulPriceVolume cumulVolume
Risk % of capital10int · min 1qty1
Stop Loss8int · min 1qty1 stopLossVal stopLossValUpside shortTakeProfit
take partial profits (percentage same as stop loss)trueboolclose SE close LE line 63
Trade DirectionLONGstring · options ["LONG", "SHORT"]rentryCondition1 rentryCondition2 stopLossValUpside shortTakeProfit entry LE close LE entry SE close SE

What it calculates

  • EMA (ema, ta.ema in v5)close, EMA Length (25)emaVal · line 16
  • EMA (ema, ta.ema in v5)cumValue, EMA Length (25)emaCumValue1 · line 17
  • EMA (ema, ta.ema in v5)cumValue, emaLength*2emaCumValue2 · line 18
  • EMA (ema, ta.ema in v5)cumValue[emaLength], EMA Length (25)emaCumValueHistory · line 19
  • RSI (rsi, ta.rsi in v5)close, 5rsiVal · line 21

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 · 25lowlowprice datahighhighprice datavolumevolumeprice datacumulativePeriodcumulative volume Periodsetting · 100riskCapitalRisk % of capitalsetting · 10stopLossStop Losssetting · 8tradeDirectionTrade Directionsetting · LONGopenopenprice dataemaValEMA→ emaValemaCumValue1EMA→ emaCumValue1emaCumValue2EMA→ emaCumValue2emaCumValueHistoryEMA→ emaCumValueHistoryrsiValRSI→ rsiValavgPriceavgPricevalueavgPriceVolumeavgPriceVolumevaluecumulPriceVolumecumulPriceVolumevaluecumulVolumecumulVolumevaluecumValuecumValuevalueqty1qty1valuestopLossValstopLossValvaluetakeProfit, profitValtakeProfit · profitVal2 valuesstopLossValUpside, shortTakeProfitstopLossValUpside · sho…2 valuesrentryCondition1rentryCondition1conditionrentryCondition2rentryCondition2conditionentry:LEOpen LEstrategy.entryclose:LEClose LEstrategy.closeentry:SEOpen SEstrategy.entryclose:SEClose SEstrategy.closeplot:22EMAplotplot:25emaVwapValueplotplot:26emaVwapValueplotfill:ema and cum areaema and cum areafillplot:28emaCumValueHistoryplot

Order rules

OrderFires whenBy defaultLine
Open LE longstrategy.position_size==0 and crossover(emaVal, emaCumValue1) and (tradeDirection=="LONG")On36
Open LE longrentryCondition1strategy.position_size>1 and emaVal > emaCumValue1 and emaCumValue1>emaCumValue2 and crossover(close, emaCumValue2) and close>open and (tradeDirection=="LONG")On39
Close LE(tradeDirection=="LONG" ) and takePartialProfits == true and close>=takeProfit and crossunder(rsiVal,90)On50
Close LEcrossunder(emaVal, emaCumValue1) and (tradeDirection=="LONG")On53
Close LEclose < stopLossVal and (tradeDirection=="LONG")On54
Open SE shortcrossunder(emaVal, emaCumValue1) and (tradeDirection=="SHORT")On56
Close SE(tradeDirection=="SHORT" ) and crossover(rsiVal,15)On64
Close SEabs(strategy.position_size)>=1 and crossover(emaVal, emaCumValue1) and (tradeDirection=="SHORT" )On69

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−4.1%+102.5%450%0.9023.8%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+9.4%+5.5%633%1.9410.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−26.0%+9.8%729%0.1028.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+19.4%+8.4%1070%2.3512.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−4.1%+16.7%956%0.8927.9%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+5.6%+21.5%978%1.4611.4%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−1.9%+148.3%863%0.9318.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−13.0%+17.1%1354%0.4813.7%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 market450%−$406.40
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?

33.2%

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

0%38%
All 4 trades
SideEntryExitBarsP&L
long29 Jul 2024 68,249.905 Aug 2024 58,161.007−$1,478.23
long27 Sep 2024 65,174.0027 Feb 2025 84,250.10153$2,494.28
long4 May 2025 95,856.4018 Oct 2025 106,432.00167$1,215.33
long26 Apr 2026 77,625.007 Jun 2026 60,884.6042−$2,637.79

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 V2] this page—v4 strategy−4.1%423.8%
RSI Cross [xaurr] by livetrendrsi emav4 strategy+24.4%5335.3%
Bitpanda Coinrule Template by joshuajcoop01rsi emav5 strategy−2.8%44.6%
RSI with Slow and Fast MA Crossing Strategy (by Coinrule) by Coinrulersi emav5 strategy−2.8%44.6%
RSI of VWAP by mohaneersi emav4 strategyNo trades on this market
EMA SCALPEUR + RSi - SHORT by YukalMoonrsi emav5 strategyNo trades on this market

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 20 msWith a workaround 1,000 bars in 86 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 36, 39, 56) 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=5, default_qty_type=strategy.percent_of_equity,  default_qty_value=20, initial_capital=10000)emaLength= input(25, 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(true, 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)cumValue = cumulPriceVolume / cumulVolumeemaVal=ema(close, emaLength)emaCumValue1=ema(cumValue, emaLength)emaCumValue2=ema(cumValue, emaLength*2)emaCumValueHistory=ema(cumValue[emaLength], emaLength)//vwapVal1=vwap(hlc3)rsiVal=rsi(close,5)plotEma=plot(emaVal, title="EMA", color=color.green,  transp=25)//plot(vwapValue, title="Cumulate Volumne", color=color.orange,  linewidth=2, transp=25)//plot(vwapVal1, title="vwapVal1", color=color.purple,  linewidth=1, transp=25)plotCum=plot(emaCumValue1, title="emaVwapValue", color=color.purple,  linewidth=2, transp=35)plot(emaCumValue2, title="emaVwapValue", color=color.yellow,  linewidth=3, transp=25)fill(plotEma,plotCum, color=emaVal>emaCumValue1 ? color.lime : color.red, transp=35, title="ema and cum area")plot(emaCumValueHistory, title="emaCumValueHistory", color=color.black,  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) : 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", long=true, qty=qty1, when=strategy.position_size==0 and crossover(emaVal, emaCumValue1)  and (tradeDirection=="LONG") )    //emaVal>vwapValue and crossover(close , emaVal)//re-entryrentryCondition1=strategy.position_size>1 and emaVal > emaCumValue1 and emaCumValue1>emaCumValue2 and crossover(close, emaCumValue2) and close>open and  (tradeDirection=="LONG")strategy.entry(id="LE",comment="LE RE", long=true, qty=qty1, when=rentryCondition1 )rentryCondition2=strategy.position_size>1 and emaVal > emaCumValue1 and emaCumValue1>emaCumValueHistory and crossover(close, emaCumValueHistory) and close>open and  (tradeDirection=="LONG")//strategy.entry(id="LE",comment="LE RE", long=true, qty=qty1, when=rentryCondition2 )    //stoplossstopLossVal=  strategy.position_size>=1 ?  (strategy.position_avg_price * (1-(stopLoss*0.01) )) : 0.00//draw initil stop loss//plot(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+(1*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="PExit Points=>"+tostring(close-strategy.position_avg_price, "###.##") , qty=strategy.position_size/3 , when = (tradeDirection=="LONG" ) and  takePartialProfits == true and close>=takeProfit and crossunder(rsiVal,90) )profitVal=    strategy.position_size>=1 ?  (strategy.position_avg_price * (1+(1*0.01) )) : ( close[1] * 2 )//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="Exit Points=>"+tostring(close-strategy.position_avg_price, "###.##"), when=  crossunder(emaVal, emaCumValue1) 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=crossunder(emaVal, emaCumValue1) 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 loss//plot(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  crossover(rsiVal,15) )  //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<emaCumValue1 and close>emaCumValue1 and open>emaCumValue1 and close>open )   or (crossover(emaVal,emaCumValue1))  ) 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="+tostring(close-strategy.position_avg_price, "###.##"), when= abs(strategy.position_size)>=1 and  crossover(emaVal, emaCumValue1)   and (tradeDirection=="SHORT"   ) )