Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Long only strategy VWAP with BB and Golden Cross EMA50-200

A Pine Script v4 strategy built on EMA (close, 200), VWAP (close) and SMA (close, 7). It has 3 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. 14 settings; defaults include From Day 1, From Month 6 and From Year 2020.

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 Long only strategy VWAP with BB and Golden Cross EMA50-200 repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Long only strategy VWAP with BB and Golden Cross EMA50-200 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 code limits trading to a date window, which can leave this period out. On BTCUSDT 4h it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
Can Long only strategy VWAP with BB and Golden Cross EMA50-200 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 Long only strategy VWAP with BB and Golden Cross EMA50-200 use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Long only strategy VWAP with BB and Golden Cross EMA50-200 run in Zeal Terminal?
Yes
It compiles in 20 ms and runs 1,000 bars in 71 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 (14)
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 96, 98) so the engine trades the way the script says. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
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 68

    Line 68 hard-codes 200 where line 66 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 96, 98, 100. The upgraded version below moves each call inside an if block.

  • Note

    Uses iff(), which v5 removed line 17

    iff() on line 17, 19, 21, 23. v5 writes it as the ternary c ? a : b.

  • Note

    Uses transp =, which v5 removed line 72

    transp = on line 72, 73, 74, 88, 89. v5 folds the transparency into the colour with color.new(c, transp).

  • Note

    Uses long =, which v5 renamed line 96

    long = on line 96, 98. 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.
  • 3 strategy calls use the when = argument (line 96, 98, 100). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 17: iff(c, a, b) → (c ? a : b)
  • Line 19: iff(c, a, b) → (c ? a : b)
  • Line 21: iff(c, a, b) → (c ? a : b)
  • Line 23: iff(c, a, b) → (c ? a : b)
  • Line 58: input(type = input.string) → input.string()
15 more edits
  • Line 66: ema → ta.ema
  • Line 67: ema → ta.ema
  • Line 68: ema → ta.ema
  • Line 69: vwap → ta.vwap
  • Line 72: transp = 0 → color.new(color.green, 0)
  • Line 73: transp = 0 → color.new(color.orange, 0)
  • Line 74: transp = 0 → color.new(color.purple, 0)
  • Line 77: sma → ta.sma
  • Line 78: stdev → ta.stdev
  • Line 81: input(type = input.integer) → input.int()
  • Line 88: transp = 95 → color.new(#198787, 95)
  • Line 89: transp = 0 → color.new(color.purple, 0)
  • Line 96: long = true → direction = strategy.long
  • Line 98: long = true → direction = strategy.long
  • Line 100: crossover → ta.crossover
⋯// © mohanee-//@version=4+//@version=5strategy(title="VWAP and BB strategy [$$]", overlay=true,pyramiding=2, default_qty_value=1, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)⋯//--- Europe-London = iff(DST==0,"0000-0900","0100-1000")+London = (DST==0 ? "0000-0900" : "0100-1000")//--- America-NewYork = iff(DST==0,"0400-1300","0500-1400")+NewYork = (DST==0 ? "0400-1300" : "0500-1400")//--- Pacific-Sydney = iff(DST==0,"1300-2200","1400-2300")+Sydney = (DST==0 ? "1300-2200" : "1400-2300")//--- Asia-Tokyo = iff(DST==0,"1500-2400","1600-0100")+Tokyo = (DST==0 ? "1500-2400" : "1600-0100")//-- Time In Range⋯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="long", 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="long", 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="long", comment="Add" , long=true,  when=strategy.position_size>=1 and close<strategy.position_avg_price and close>vwapVal) //and time_cond)+strategy.entry(id="long", comment="Add" , direction = strategy.long,  when=strategy.position_size>=1 and close<strategy.position_avg_price and close>vwapVal) //and time_cond)barcolor(strategy.position_size>=1  ? color.blue: na)-strategy.close(id="long", comment="TP Exit",   when=crossover(close,upperBand) )+strategy.close(id="long", comment="TP Exit",   when=ta.crossover(close,upperBand) )//stoploss⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 5: input() → input.int()
  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 10: input() → input.int()
  • Line 11: input() → input.int()
  • Line 12: input() → input.int()
9 more edits
  • Line 53: input() → input.int()
  • Line 54: input() → input.int()
  • Line 56: input() → input.int()
  • Line 57: input() → input.source()
  • Line 64: input() → input.int()
  • Line 76: input() → input.float()
  • Line 96: 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 98: when = strategy.position_size>=1 and close<strategy.position_avg_price and close>vwapVal → if block
  • Line 100: when = ta.crossover(close,upperBand) → if block
⋯strategy(title="VWAP and BB strategy [$$]", overlay=true,pyramiding=2, default_qty_value=1, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)-fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)+fromDay = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)-fromMonth = input(defval = 6, title = "From Month", minval = 1, maxval = 12)+fromMonth = input.int(defval = 6, title = "From Month", minval = 1, maxval = 12)-fromYear = input(defval = 2020, title = "From Year", minval = 1970)+fromYear = input.int(defval = 2020, title = "From Year", minval = 1970) // To Date Inputs-toDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)+toDay = input.int(defval = 1, title = "To Day", minval = 1, maxval = 31)-toMonth = input(defval = 8, title = "To Month", minval = 1, maxval = 12)+toMonth = input.int(defval = 8, title = "To Month", minval = 1, maxval = 12)-toYear = input(defval = 2020, title = "To Year", minval = 1970)+toYear = input.int(defval = 2020, title = "To Year", minval = 1970) ⋯// variables  BEGIN-shortEMA = input(50, title="fast EMA", minval=1)+shortEMA = input.int(50, title="fast EMA", minval=1)-longEMA = input(200, title="slow EMA", minval=1)+longEMA = input.int(200, title="slow EMA", minval=1)//BB-smaLength = input(7, title="BB SMA Length", minval=1)+smaLength = input.int(7, 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=1, minval=1)+stopLoss = input.int(title="Stop Loss%", defval=1, 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="long", 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="long", 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="long", comment="Add" , direction = strategy.long,  when=strategy.position_size>=1 and close<strategy.position_avg_price and close>vwapVal) //and time_cond)+if strategy.position_size>=1 and close<strategy.position_avg_price and close>vwapVal+    strategy.entry(id="long", comment="Add" , direction = strategy.long) //and time_cond)barcolor(strategy.position_size>=1  ? color.blue: na)-strategy.close(id="long", comment="TP Exit",   when=ta.crossover(close,upperBand) )+if ta.crossover(close,upperBand)+    strategy.close(id="long", comment="TP Exit" )//stoploss⋯

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: 26 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 [$$]", 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
From Day1int · min 1 · max 31startDate
From Month6int · min 1 · max 12startDate
From Year2020int · min 1970startDate
To Day1int · min 1 · max 31finishDate
To Month8int · min 1 · max 12finishDate
To Year2020int · min 1970finishDate
fast EMA50int · min 1shortEMAval
slow EMA200int · min 1longEMAval
BB SMA Length7int · min 1basis dev
BB Sourceclosesourcebasis dev bbr
strategy to useBBstring · options ["BB", "BB_percentageB"]entry long
Stop Loss%1int · 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 (200)longEMAval · line 66
  • EMA (ema, ta.ema in v5)close, fast EMA (50)shortEMAval · line 67
  • EMA (ema, ta.ema in v5)close, 200ema200val · line 68
  • VWAP (vwap, ta.vwap in v5)closevwapVal · line 69
  • SMA (sma, ta.sma in v5)BB Source (close), BB SMA Length (7)basis · line 77
  • Stdev (stdev, ta.stdev in v5)BB Source (close), BB SMA Length (7)dev · line 78

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 · 200shortEMAfast EMAsetting · 50hlc3 · volumehlc3 · volumeprice datasmaLengthBB SMA Lengthsetting · 7multStdDevsetting · 2.0fromYearFrom Yearsetting · 2020fromMonthFrom Monthsetting · 6fromDayFrom Daysetting · 1toYearTo Yearsetting · 2020toMonthTo Monthsetting · 8toDayTo Daysetting · 1stopLossStop Loss%setting · 1timetimeprice dataopenopenprice datastrategyCalcOptionstrategy to usesetting · BBlongEMAvalEMA→ longEMAvalshortEMAvalEMA→ shortEMAvalema200valEMA→ ema200valvwapValVWAP→ vwapValbasisSMA→ basisdevStdev→ devlondonlondonvaluenewyorknewyorkvaluestartDatestartDatevaluefinishDatefinishDatevaluet_bbDippedt_bbDippedvalueupperBand, lowerBandupperBand · lowerBand2 valuesbbrbbrvaluestopLossValstopLossValvalueLondon, NewYork, Sydney, TokyoLondon · NewYork +24 conditionstime_condtime_condconditionlongConditionlongConditionconditionentry:longOpen longstrategy.entryclose:longClose longstrategy.closeplot:72plotplotplot:73plotplotplot:74plotplotplot:86Upperplotplot:87Lowerplotfill:BackgroundBackgroundfillplot:89plotplotbarcolor:99barcolorbarcolor

Order rules

OrderFires whenBy defaultLine
Open long longlongCondition and ( strategyCalcOption=="BB"? is_price_dipped_bb(10,lowerBand) : is_bb_per_dipped(10,bbr) ) and strategy.position_size<1On96
Open long longstrategy.position_size>=1 and close<strategy.position_avg_price and close>vwapValOn98
Close longcrossover(close,upperBand)On100

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+202.1%+5.5%2662%3.1066.4%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+8.8%+8.4%3367%2.485.5%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.4%+21.5%2972%2.090.3%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+2.8%+17.1%2774%3.151.3%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
Long only strategy VWAP with BB and Golden Cross EMA50-200 this page—v4 strategy0.0%00.0%
VWAP and BB strategy [EEMANI] by mohaneeema vwap sma stdevv4 strategyNo trades on this market
Buying Selling Volume Strategy by exlux99vwap ema sma stdevv5 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 20 msWith a workaround 1,000 bars in 71 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 96, 98) so the engine trades the way the script says. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.

“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 [$$]", overlay=true,pyramiding=2, default_qty_value=1, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)fromMonth = input(defval = 6, title = "From Month", minval = 1, maxval = 12)fromYear = input(defval = 2020, title = "From Year", minval = 1970) // To Date InputstoDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)toMonth = input(defval = 8, title = "To Month", minval = 1, maxval = 12)toYear = input(defval = 2020, title = "To Year", minval = 1970) // Calculate start/end date and time conditionDST = 1 //day light saving for usa//--- EuropeLondon = iff(DST==0,"0000-0900","0100-1000")//--- AmericaNewYork = iff(DST==0,"0400-1300","0500-1400")//--- PacificSydney = iff(DST==0,"1300-2200","1400-2300")//--- AsiaTokyo = iff(DST==0,"1500-2400","1600-0100")//-- Time In Rangetimeinrange(res, sess) => time(res, sess) != 0london = timeinrange(timeframe.period, London)newyork = timeinrange(timeframe.period, NewYork)startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)finishDate = timestamp(toYear, toMonth, toDay, 00, 00)time_cond = time >= startDate and time <= finishDate 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(50, title="fast EMA", minval=1)longEMA = input(200, title="slow EMA", minval=1)//BBsmaLength = input(7, 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=1, 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 time_cond //     and  close>=vwapVal //Entrystrategy.entry(id="long", 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="long", comment="Add" , long=true,  when=strategy.position_size>=1 and close<strategy.position_avg_price and close>vwapVal) //and time_cond)barcolor(strategy.position_size>=1  ? color.blue: na)strategy.close(id="long", comment="TP Exit",   when=crossover(close,upperBand) )//stoplossstopLossVal =   strategy.position_avg_price * (1-(stopLoss*0.01) )//strategy.close(id="long", comment="SL Exit",   when= close < stopLossVal)//strategy.risk.max_intraday_loss(stopLoss, strategy.percent_of_equity)