Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

VWAP and BB strategy [EEMANI]

A Pine Script v4 strategy built on EMA (close, 55), VWAP (close) and SMA (close, 20). It has 4 order rules, 2 entries among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 8 settings; defaults include fast EMA 13, slow EMA 55 and BB SMA Length 20.

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 VWAP and BB strategy [EEMANI] repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did VWAP and BB strategy [EEMANI] do on BTCUSDT 1D with default settings?
Not measured
It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its entry conditions never all held on this data. On BTCUSDT 4h it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
Can VWAP and BB strategy [EEMANI] 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 VWAP and BB strategy [EEMANI] use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does VWAP and BB strategy [EEMANI] run in Zeal Terminal?
Yes
It compiles in 16 ms and runs 1,000 bars in 54 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • Plot
  • Upper
  • Lower
  • Plot
  • 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 (8)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$10,000$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 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 79, 81) so the engine trades the way the script says.
Net profit
0.00%
$0.00
Buy and hold
+102.5%
same period
Closed trades
0
0 won · 0 lost
Profitable
0.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
0.00%
$0.00

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

  • Likely bug

    ema(close, 200) ignores the settings line 51

    Line 51 hard-codes 200 where line 49 uses “slow EMA”. Changing those settings moves one band but not this one.

    ema(close, 200)ema(close, longEMA)
  • 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 79, 81, 83, 86. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 55

    transp = on line 55, 56, 57, 71, 72. v5 folds the transparency into the colour with color.new(c, transp).

  • Note

    Uses long =, which v5 renamed line 79

    long = on line 79, 81. 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 ema → ta.ema, vwap → ta.vwap, sma → ta.sma, stdev → ta.stdev, crossover → ta.crossover.
  • 4 strategy calls use the when = argument (line 79, 81, 83, 86). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 41: input(type = input.string) → input.string()
  • Line 49: ema → ta.ema
  • Line 50: ema → ta.ema
  • Line 51: ema → ta.ema
  • Line 52: vwap → ta.vwap
11 more edits
  • Line 55: transp = 0 → color.new(color.green, 0)
  • Line 56: transp = 0 → color.new(color.orange, 0)
  • Line 57: transp = 0 → color.new(color.purple, 0)
  • Line 60: sma → ta.sma
  • Line 61: stdev → ta.stdev
  • Line 64: input(type = input.integer) → input.int()
  • Line 71: transp = 95 → color.new(#198787, 95)
  • Line 72: transp = 0 → color.new(color.purple, 0)
  • Line 79: long = true → direction = strategy.long
  • Line 81: long = true → direction = strategy.long
  • Line 83: crossover → ta.crossover
⋯// © mohanee-//@version=4+//@version=5strategy(title="VWAP and BB strategy [EEMANI]", overlay=true,pyramiding=2, default_qty_value=1, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)⋯bbsrc = input(close, title="BB Source")-strategyCalcOption = input(title="strategy to use", type=input.string, options=["BB", "BB_percentageB"],      defval="BB")+strategyCalcOption = input.string(title="strategy to use", options=["BB", "BB_percentageB"],      defval="BB")//addOnDivergence = input(true,title="Add to existing on Divergence")⋯//variables  END-longEMAval= ema(close, longEMA)+longEMAval= ta.ema(close, longEMA)-shortEMAval= ema(close, shortEMA)+shortEMAval= ta.ema(close, shortEMA)-ema200val = ema(close, 200)+ema200val = ta.ema(close, 200)-vwapVal=vwap(close)+vwapVal=ta.vwap(close)// Drawings//plot emas-plot(shortEMAval, color = color.green, linewidth = 1, transp=0)+plot(shortEMAval, color = color.new(color.green, 0), linewidth = 1)-plot(longEMAval, color = color.orange, linewidth = 1, transp=0)+plot(longEMAval, color = color.new(color.orange, 0), linewidth = 1)-plot(ema200val, color = color.purple, linewidth = 2, style=plot.style_line ,transp=0)+plot(ema200val, color = color.new(color.purple, 0), linewidth = 2, style=plot.style_line )//bollinger calculation mult = input(2.0, minval=0.001, maxval=50, title="StdDev")-basis = sma(bbsrc, smaLength)+basis = ta.sma(bbsrc, smaLength)-dev = mult * stdev(bbsrc, smaLength)+dev = mult * ta.stdev(bbsrc, smaLength)upperBand = basis + devlowerBand = basis - dev-offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)+offset = input.int(0, "Offset", minval = -500, maxval = 500)bbr = (bbsrc - lowerBand)/(upperBand - lowerBand) ⋯p2 = plot(lowerBand, "Lower", color=color.teal, offset = offset)-fill(p1, p2, title = "Background", color=#198787, transp=95)+fill(p1, p2, title = "Background", color=color.new(#198787, 95))-plot(vwapVal, color = color.purple, linewidth = 2, transp=0)+plot(vwapVal, color = color.new(color.purple, 0), linewidth = 2)// Colour background⋯//Entry-strategy.entry(id="VWAP_BB LE", comment="VB LE" , long=true,  when= longCondition and ( strategyCalcOption=="BB"? is_price_dipped_bb(10,lowerBand) : is_bb_per_dipped(10,bbr)  )   and strategy.position_size<1 )   //is_price_dipped_bb(10,lowerBand))  //and strategy.position_size<1       is_bb_per_dipped(15,bbr) +strategy.entry(id="VWAP_BB LE", comment="VB LE" , direction = strategy.long,  when= longCondition and ( strategyCalcOption=="BB"? is_price_dipped_bb(10,lowerBand) : is_bb_per_dipped(10,bbr)  )   and strategy.position_size<1 )   //is_price_dipped_bb(10,lowerBand))  //and strategy.position_size<1       is_bb_per_dipped(15,bbr) //add to the existing position-strategy.entry(id="VWAP_BB LE", comment="Add" , long=true,  when=strategy.position_size>=1 and close<strategy.position_avg_price and close>vwapVal )+strategy.entry(id="VWAP_BB LE", comment="Add" , direction = strategy.long,  when=strategy.position_size>=1 and close<strategy.position_avg_price and close>vwapVal )barcolor(strategy.position_size>=1  ? color.blue: na)-strategy.close(id="VWAP_BB LE", comment="TP Exit",   when=crossover(close,upperBand) )+strategy.close(id="VWAP_BB LE", comment="TP Exit",   when=ta.crossover(close,upperBand) )//stoploss⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 36: input() → input.int()
  • Line 37: input() → input.int()
  • Line 39: input() → input.int()
  • Line 40: input() → input.source()
  • Line 47: input() → input.int()
  • Line 59: input() → input.float()
4 more edits
  • Line 79: when = longCondition and ( strategyCalcOption=="BB"? is_price_dipped_bb(10,lowerBand) : is_bb_per_dipped(10,bbr) ) and strategy.position_size<1 → if block
  • Line 81: when = strategy.position_size>=1 and close<strategy.position_avg_price and close>vwapVal → if block
  • Line 83: when = ta.crossover(close,upperBand) → if block
  • Line 86: when = close < stopLossVal → if block
⋯// variables  BEGIN-shortEMA = input(13, title="fast EMA", minval=1)+shortEMA = input.int(13, title="fast EMA", minval=1)-longEMA = input(55, title="slow EMA", minval=1)+longEMA = input.int(55, title="slow EMA", minval=1)//BB-smaLength = input(20, title="BB SMA Length", minval=1)+smaLength = input.int(20, title="BB SMA Length", minval=1)-bbsrc = input(close, title="BB Source")+bbsrc = input.source(close, title="BB Source")strategyCalcOption = input.string(title="strategy to use", options=["BB", "BB_percentageB"],      defval="BB")⋯//vwap_res = input(title="VWAP Resolution", type=input.resolution, defval="session")-stopLoss = input(title="Stop Loss%", defval=5, minval=1)+stopLoss = input.int(title="Stop Loss%", defval=5, minval=1)//variables  END⋯//bollinger calculation -mult = input(2.0, minval=0.001, maxval=50, title="StdDev")+mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")basis = ta.sma(bbsrc, smaLength)⋯//Entry-strategy.entry(id="VWAP_BB LE", comment="VB LE" , direction = strategy.long,  when= longCondition and ( strategyCalcOption=="BB"? is_price_dipped_bb(10,lowerBand) : is_bb_per_dipped(10,bbr)  )   and strategy.position_size<1 )   //is_price_dipped_bb(10,lowerBand))  //and strategy.position_size<1       is_bb_per_dipped(15,bbr) +if longCondition and ( strategyCalcOption=="BB"? is_price_dipped_bb(10,lowerBand) : is_bb_per_dipped(10,bbr)  )   and strategy.position_size<1+    strategy.entry(id="VWAP_BB LE", comment="VB LE" , direction = strategy.long )   //is_price_dipped_bb(10,lowerBand))  //and strategy.position_size<1       is_bb_per_dipped(15,bbr) //add to the existing position-strategy.entry(id="VWAP_BB LE", comment="Add" , direction = strategy.long,  when=strategy.position_size>=1 and close<strategy.position_avg_price and close>vwapVal )+if strategy.position_size>=1 and close<strategy.position_avg_price and close>vwapVal+    strategy.entry(id="VWAP_BB LE", comment="Add" , direction = strategy.long )barcolor(strategy.position_size>=1  ? color.blue: na)-strategy.close(id="VWAP_BB LE", comment="TP Exit",   when=ta.crossover(close,upperBand) )+if ta.crossover(close,upperBand)+    strategy.close(id="VWAP_BB LE", comment="TP Exit" )//stoplossstopLossVal =   strategy.position_avg_price * (1-(stopLoss*0.01) )-strategy.close(id="VB LE", comment="SL Exit",   when= close < stopLossVal)+if close < stopLossVal+    strategy.close(id="VB LE", comment="SL Exit")

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: 8 before, 0 after on BTCUSDT 4h, 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(title="VWAP and BB strategy [EEMANI]", overlay=true,pyramiding=2, default_qty_value=1, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)⋯

Settings

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

SettingDefaultType and rangeFeeds
fast EMA13int · min 1shortEMAval
slow EMA55int · min 1longEMAval
BB SMA Length20int · min 1basis dev
BB Sourceclosesourcebasis dev bbr
strategy to useBBstring · options ["BB", "BB_percentageB"]entry VWAP_BB LE
Stop Loss%5int · min 1stopLossVal
StdDev2.0float · min 0.001 · max 50dev
Offset0int (written input.integer) · min -500 · max 500Upper Lower

What it calculates

  • EMA (ema, ta.ema in v5)close, slow EMA (55)longEMAval · line 49
  • EMA (ema, ta.ema in v5)close, fast EMA (13)shortEMAval · line 50
  • EMA (ema, ta.ema in v5)close, 200ema200val · line 51
  • VWAP (vwap, ta.vwap in v5)closevwapVal · line 52
  • SMA (sma, ta.sma in v5)BB Source (close), BB SMA Length (20)basis · line 60
  • Stdev (stdev, ta.stdev in v5)BB Source (close), BB SMA Length (20)dev · line 61

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 datalongEMAslow EMAsetting · 55shortEMAfast EMAsetting · 13hlc3 · volumehlc3 · volumeprice datasmaLengthBB SMA Lengthsetting · 20multStdDevsetting · 2.0stopLossStop Loss%setting · 5openopenprice datastrategyCalcOptionstrategy to usesetting · BBlongEMAvalEMA→ longEMAvalshortEMAvalEMA→ shortEMAvalema200valEMA→ ema200valvwapValVWAP→ vwapValbasisSMA→ basisdevStdev→ devt_bbDippedt_bbDippedvalueupperBand, lowerBandupperBand · lowerBand2 valuesbbrbbrvaluestopLossValstopLossValvaluelongConditionlongConditionconditionentry:VWAP_BB LEOpen VWAP_BB LEstrategy.entryclose:VWAP_BB LEClose VWAP_BB LEstrategy.closeclose:VB LEClose VB LEstrategy.closeplot:55plotplotplot:56plotplotplot:57plotplotplot:69Upperplotplot:70Lowerplotfill:BackgroundBackgroundfillplot:72plotplotbarcolor:82barcolorbarcolor

Order rules

OrderFires whenBy defaultLine
Open VWAP_BB LE longlongCondition and ( strategyCalcOption=="BB"? is_price_dipped_bb(10,lowerBand) : is_bb_per_dipped(10,bbr) ) and strategy.position_size<1On79
Open VWAP_BB LE longstrategy.position_size>=1 and close<strategy.position_avg_price and close>vwapValOn81
Close VWAP_BB LEcrossover(close,upperBand)On83
Close VB LEclose < stopLossValOn86

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • 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 1D0.0%+102.5%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+103.2%+5.5%875%5.1530.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+5.2%+8.4%888%17.352.2%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.1%+21.5%1070%1.780.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%1173%1.021.4%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

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
VWAP and BB strategy [EEMANI] this page—v4 strategy0.0%00.0%
Buying Selling Volume Strategy by exlux99vwap ema sma stdevv5 strategyNo trades on this market
Long only strategy VWAP with BB and Golden Cross EMA50-200 by SoftKill21ema vwap sma stdevv4 strategyNo trades on this market
Volume Weighted Bollinger Bands Strategy by Ankit_1618ema sma stdevv4 strategy+10.0%1527.5%
BB21_MA200_Strategy by mohaneeema sma stdevv4 strategyNo trades on this market
ZVWAP strategy by mohaneesma ema vwapv4 strategy+614.4%13748.5%

Where it runs

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

Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 79, 81) 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(title="VWAP and BB strategy [EEMANI]", overlay=true,pyramiding=2, default_qty_value=1, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)//This strategy combines VWAP and BB indicators//BUY RULE//1. EMA50 > EMA 200//2. if current close > vwap session  value //3. check if  price dipped BB lower band for any of last 10 candles//EXIT RULE//1. price closes above BB upper //STOP LOSS EXIT//1. As configured --- default is set to 5%is_price_dipped_bb(pds,source1) =>    t_bbDipped=false    for i=1 to pds        t_bbDipped:=  (t_bbDipped   or  close[i]<source1) ? true : false        if t_bbDipped==true            break        else            continue                t_bbDippedis_bb_per_dipped(pds,bbrSrc) =>    t_bbDipped=false    for i=1 to pds        t_bbDipped:=  (t_bbDipped   or  bbrSrc[i]<=0) ? true : false        if t_bbDipped==true            break        else            continue                t_bbDipped    // variables  BEGINshortEMA = input(13, title="fast EMA", minval=1)longEMA = input(55, title="slow EMA", minval=1)//BBsmaLength = input(20, title="BB SMA Length", minval=1)bbsrc = input(close, title="BB Source")strategyCalcOption = input(title="strategy to use", type=input.string, options=["BB", "BB_percentageB"],      defval="BB")//addOnDivergence = input(true,title="Add to existing on Divergence")//exitOption = input(title="exit on RSI or BB", type=input.string, options=["RSI", "BB"],      defval="BB")//bbSource = input(title="BB  source", type=input.string, options=["close", "vwap"],      defval="close")     //vwap_res = input(title="VWAP Resolution", type=input.resolution, defval="session")stopLoss = input(title="Stop Loss%", defval=5, minval=1)//variables  ENDlongEMAval= ema(close, longEMA)shortEMAval= ema(close, shortEMA)ema200val = ema(close, 200)vwapVal=vwap(close)// Drawings//plot emasplot(shortEMAval, color = color.green, linewidth = 1, transp=0)plot(longEMAval, color = color.orange, linewidth = 1, transp=0)plot(ema200val, color = color.purple, linewidth = 2, style=plot.style_line ,transp=0)//bollinger calculation mult = input(2.0, minval=0.001, maxval=50, title="StdDev")basis = sma(bbsrc, smaLength)dev = mult * stdev(bbsrc, smaLength)upperBand = basis + devlowerBand = basis - devoffset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)bbr = (bbsrc - lowerBand)/(upperBand - lowerBand) //bollinger calculation //plot bb//plot(basis, "Basis", color=#872323, offset = offset)p1 = plot(upperBand, "Upper", color=color.teal, offset = offset)p2 = plot(lowerBand, "Lower", color=color.teal, offset = offset)fill(p1, p2, title = "Background", color=#198787, transp=95)plot(vwapVal, color = color.purple, linewidth = 2, transp=0)// Colour background//barcolor(shortEMAval>longEMAval and close<=lowerBand ? color.yellow: na)  //longCondition=  shortEMAval > longEMAval and  close>open and  close>vwapVallongCondition=  ( shortEMAval > longEMAval  and close>open and close>vwapVal and close<upperBand ) //     and  close>=vwapVal //Entrystrategy.entry(id="VWAP_BB LE", comment="VB LE" , long=true,  when= longCondition and ( strategyCalcOption=="BB"? is_price_dipped_bb(10,lowerBand) : is_bb_per_dipped(10,bbr)  )   and strategy.position_size<1 )   //is_price_dipped_bb(10,lowerBand))  //and strategy.position_size<1       is_bb_per_dipped(15,bbr) //add to the existing positionstrategy.entry(id="VWAP_BB LE", comment="Add" , long=true,  when=strategy.position_size>=1 and close<strategy.position_avg_price and close>vwapVal )barcolor(strategy.position_size>=1  ? color.blue: na)strategy.close(id="VWAP_BB LE", comment="TP Exit",   when=crossover(close,upperBand) )//stoplossstopLossVal =   strategy.position_avg_price * (1-(stopLoss*0.01) )strategy.close(id="VB LE", comment="SL Exit",   when= close < stopLossVal)