Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Bollinger Band with Fib Golden Ratio (0.618)

A Pine Script v4 strategy built on VWMA (hlc3, 50), Stdev (hlc3, 50) and EMA (close, 200). It has 3 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 20% of equity and pays no commission. 4 settings; defaults include BB Length 50, Source hlc3 and multplier 1.5.

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 Bollinger Band with Fib Golden Ratio (0.618) repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Bollinger Band with Fib Golden Ratio (0.618) 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; it opened a long position that was still open on the last bar, so there is no result to report. On ETHUSDT 4h it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
Can Bollinger Band with Fib Golden Ratio (0.618) 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 Bollinger Band with Fib Golden Ratio (0.618) use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Bollinger Band with Fib Golden Ratio (0.618) run in Zeal Terminal?
Yes
It compiles in 14 ms and runs 1,000 bars in 35 ms, in the browser.

BTCUSDT · 1D · default settings

  • 0.618
  • Plot
  • 0.618 entry
  • ema200
  • ema50
  • 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 (4)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$9,782$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 (line 26) 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
7.84%
−$783.93

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 26, 27, 30. The upgraded version below moves each call inside an if block.

  • Note

    Uses long =, which v5 renamed line 26

    long = on line 26. 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 vwma → ta.vwma, stdev → ta.stdev, ema → ta.ema, tostring → str.tostring, crossover → ta.crossover, abs → math.abs.
  • 3 strategy calls use the when = argument (line 26, 27, 30). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 10: vwma → ta.vwma
  • Line 11: stdev → ta.stdev
  • Line 21: ema → ta.ema
  • Line 22: ema → ta.ema
  • Line 26: long = true → direction = strategy.long
4 more edits
  • Line 27: tostring → str.tostring
  • Line 27: crossover → ta.crossover
  • Line 30: tostring → str.tostring
  • Line 30: abs → math.abs
⋯// © mohanee-//@version=4+//@version=5strategy(title="Bollinger Band with Fib Golden Ratio (0.618)",  shorttitle="Bollinger Band with Fib Golden Ratio" , overlay=true, pyramiding=1,     default_qty_type=strategy.percent_of_equity,  default_qty_value=20, initial_capital=10000, currency=currency.USD)  ⋯stopLoss=input(5,title="Stop Loss",minval=1)-basis = vwma(src1, length)+basis = ta.vwma(src1, length)-dev = mult * stdev(src1, length)+dev = mult * ta.stdev(src1, length)//dev3 = mult3 * stdev(src, length)⋯//plot_lower618= plot(lower_618, color=color.purple, linewidth=1, title="0.618 entry")-ema200=ema(close,200)+ema200=ta.ema(close,200)-ema50=ema(close,50)+ema50=ta.ema(close,50)plot (ema200, title="ema200", color=color.orange, linewidth=2)⋯longCondition= ema50 > ema200-strategy.entry(id="BB_Fib618", long=true, when = longCondition and ( close < lower_618  or  low <= lower_618)  )+strategy.entry(id="BB_Fib618", direction = strategy.long, when = longCondition and ( close < lower_618  or  low <= lower_618)  )-strategy.close(id="BB_Fib618",  comment="points="+tostring(close - strategy.position_avg_price,  "###.##") , when = strategy.position_size >= 1  and crossover(close,upper_618 )) +strategy.close(id="BB_Fib618",  comment="points="+str.tostring(close - strategy.position_avg_price,  "###.##") , when = strategy.position_size >= 1  and ta.crossover(close,upper_618 )) //stoploss exitstopLossVal = strategy.position_size>=1 ?  strategy.position_avg_price * ( 1 - (stopLoss/100) ) : 0.00-strategy.close(id="BB_Fib618", comment="SL="+tostring(close - strategy.position_avg_price,  "###.##"), when=abs(strategy.position_size)>=1 and close < stopLossVal ) //and close > strategy.position_avg_price )+strategy.close(id="BB_Fib618", comment="SL="+str.tostring(close - strategy.position_avg_price,  "###.##"), when=math.abs(strategy.position_size)>=1 and close < stopLossVal ) //and close > strategy.position_avg_price )

Clean v5

VerifiedDownload the v5 script

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

  • Line 5: input() → input.int()
  • Line 6: input() → input.source()
  • Line 8: input() → input.float()
  • Line 9: input() → input.int()
  • Line 26: when = longCondition and ( close < lower_618 or low <= lower_618) → if block
  • Line 27: when = strategy.position_size >= 1 and ta.crossover(close,upper_618 ) → if block
  • Line 30: when = math.abs(strategy.position_size)>=1 and close < stopLossVal → if block
⋯strategy(title="Bollinger Band with Fib Golden Ratio (0.618)",  shorttitle="Bollinger Band with Fib Golden Ratio" , overlay=true, pyramiding=1,     default_qty_type=strategy.percent_of_equity,  default_qty_value=20, initial_capital=10000, currency=currency.USD)  -length = input(50,title="BB Length" , minval=1)+length = input.int(50,title="BB Length" , minval=1)-src1 = input(hlc3, title="Source")+src1 = input.source(hlc3, title="Source")//mult1 = input(1.33, minval=0.001, maxval=50)-mult = input(1.5,title="multplier", minval=0.001, maxval=50)+mult = input.float(1.5,title="multplier", minval=0.001, maxval=50)-stopLoss=input(5,title="Stop Loss",minval=1)+stopLoss=input.int(5,title="Stop Loss",minval=1)basis = ta.vwma(src1, length)⋯longCondition= ema50 > ema200-strategy.entry(id="BB_Fib618", direction = strategy.long, when = longCondition and ( close < lower_618  or  low <= lower_618)  )+if longCondition and ( close < lower_618  or  low <= lower_618)+    strategy.entry(id="BB_Fib618", direction = strategy.long  )-strategy.close(id="BB_Fib618",  comment="points="+str.tostring(close - strategy.position_avg_price,  "###.##") , when = strategy.position_size >= 1  and ta.crossover(close,upper_618 )) +if strategy.position_size >= 1  and ta.crossover(close,upper_618 )+    strategy.close(id="BB_Fib618",  comment="points="+str.tostring(close - strategy.position_avg_price,  "###.##") ) //stoploss exitstopLossVal = strategy.position_size>=1 ?  strategy.position_avg_price * ( 1 - (stopLoss/100) ) : 0.00-strategy.close(id="BB_Fib618", comment="SL="+str.tostring(close - strategy.position_avg_price,  "###.##"), when=math.abs(strategy.position_size)>=1 and close < stopLossVal ) //and close > strategy.position_avg_price )+if math.abs(strategy.position_size)>=1 and close < stopLossVal+    strategy.close(id="BB_Fib618", comment="SL="+str.tostring(close - strategy.position_avg_price,  "###.##") ) //and close > strategy.position_avg_price )

Does it run in Pine Script v6?

Yes

Same 5 trades and the same P&L on ETHUSDT 4h, 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(title="Bollinger Band with Fib Golden Ratio (0.618)",  shorttitle="Bollinger Band with Fib Golden Ratio" , overlay=true, pyramiding=1,     default_qty_type=strategy.percent_of_equity,  default_qty_value=20, 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
BB Length50int · min 1basis dev
Sourcehlc3sourcebasis dev
multplier1.5float · min 0.001 · max 50dev
Stop Loss5int · min 1stopLossVal

What it calculates

  • VWMA (vwma, ta.vwma in v5)Source (hlc3), BB Length (50)basis · line 10
  • Stdev (stdev, ta.stdev in v5)Source (hlc3), BB Length (50)dev · line 11
  • EMA (ema, ta.ema in v5)close, 200ema200 · line 21
  • EMA (ema, ta.ema in v5)close, 50ema50 · line 22

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.

hlc3hlc3price datalengthBB Lengthsetting · 50multmultpliersetting · 1.5closecloseprice datastopLossStop Losssetting · 5lowlowprice databasisVWMA→ basisdevStdev→ devema200EMA→ ema200ema50EMA→ ema50upper_618, lower_618upper_618 · lower_6182 valuesstopLossValstopLossValvaluelongConditionlongConditionconditionentry:BB_Fib618Open BB_Fib618strategy.entryclose:BB_Fib618Close BB_Fib618strategy.closeplot:160.618plotplot:17plotplotplot:180.618 entryplotplot:23ema200plotplot:24ema50plot

Order rules

OrderFires whenBy defaultLine
Open BB_Fib618 longlongCondition and ( close < lower_618 or low <= lower_618)On26
Close BB_Fib618strategy.position_size >= 1 and crossover(close,upper_618 )On27
Close BB_Fib618abs(strategy.position_size)>=1 and close < stopLossValOn30

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%—7.8%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.6%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—11.7%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+2.9%+8.4%5100%—0.8%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−10.7%+16.7%147%0.4414.6%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−1.2%+21.5%863%0.693.2%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.9%+148.3%1644%1.066.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+1.3%+17.1%786%2.231.6%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
Bollinger Band with Fib Golden Ratio (0.618) this page—v4 strategy0.0%07.8%
TriautoETF(TQQQ) Short Strategy B1 by BBcomvwma emav5 strategyNo trades on this market
Escaping of Rate from Avarage By Mustafa OZVER Strategy by Mustafaozverstdev emav4 strategy+122.0%9679.1%
Volume Weighted Bollinger Bands Strategy by Ankit_1618ema stdevv4 strategy+10.0%1527.5%
BB21_MA200_Strategy by mohaneeema stdevv4 strategyNo trades on this market
STR-EMA Oscilator [Azzrael] by Azzraelema stdevv5 strategy+2.3%630.6%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 14 msWith a workaround 1,000 bars in 35 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 (line 26) 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="Bollinger Band with Fib Golden Ratio (0.618)",  shorttitle="Bollinger Band with Fib Golden Ratio" , overlay=true, pyramiding=1,     default_qty_type=strategy.percent_of_equity,  default_qty_value=20, initial_capital=10000, currency=currency.USD)  length = input(50,title="BB Length" , minval=1)src1 = input(hlc3, title="Source")//mult1 = input(1.33, minval=0.001, maxval=50)mult = input(1.5,title="multplier", minval=0.001, maxval=50)stopLoss=input(5,title="Stop Loss",minval=1)basis = vwma(src1, length)dev = mult * stdev(src1, length)//dev3 = mult3 * stdev(src, length)upper_618= basis + (0.618*dev)lower_618= basis - (0.618*dev)//lower_618_dev3= basis - (0.618*dev3)plot_upper618= plot(upper_618, color=color.purple, linewidth=2, title="0.618")plot(basis, color=color.purple,style=plot.style_circles,  linewidth=2)plot_lower618= plot(lower_618, color=color.purple, linewidth=2, title="0.618 entry")//plot_lower618_dev3= plot(lower_618_dev3, color=color.red, linewidth=1, title="0.618 stop")//plot_lower618= plot(lower_618, color=color.purple, linewidth=1, title="0.618 entry")ema200=ema(close,200)ema50=ema(close,50)plot (ema200, title="ema200", color=color.orange, linewidth=2)plot (ema50, title="ema50", color=color.blue , linewidth=2)longCondition= ema50 > ema200strategy.entry(id="BB_Fib618", long=true, when = longCondition and ( close < lower_618  or  low <= lower_618)  )strategy.close(id="BB_Fib618",  comment="points="+tostring(close - strategy.position_avg_price,  "###.##") , when = strategy.position_size >= 1  and crossover(close,upper_618 )) //stoploss exitstopLossVal = strategy.position_size>=1 ?  strategy.position_avg_price * ( 1 - (stopLoss/100) ) : 0.00strategy.close(id="BB_Fib618", comment="SL="+tostring(close - strategy.position_avg_price,  "###.##"), when=abs(strategy.position_size)>=1 and close < stopLossVal ) //and close > strategy.position_avg_price )