Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Double Bollinger Strategy

A Pine Script v4 strategy built on Lowest (10), Highest (10) and Valuewhen (bought, LL). It has 12 order rules, 8 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 100% of equity and pays 0.04 commission. 17 settings; defaults include Strategy Direction 0, RSI Length 14 and Slow BB Band Length 45.

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 Double Bollinger Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 15 of 15 trades.
How did Double Bollinger Strategy do on BTCUSDT 1D with default settings?
−29.58%
From 26 Jan 2024 to 21 Oct 2026, over 61 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Double Bollinger Strategy be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does Double Bollinger Strategy use a stop loss?
Yes
strategy.exit sets a stop on line 143, 144.
Does Double Bollinger Strategy run in Zeal Terminal?
Yes
It compiles in 39 ms and runs 1,000 bars in 108 ms, in the browser.

BTCUSDT · 1D · default settings

  • Slow BB Upper Band
  • Slow BB Lower Band
  • Fast BB Upper Band
  • Fast BB Lower Band
  • SL
  • SSL
  • Bullish Setup
  • Bearish Setup
  • 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 (17)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$7,042$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.
Net profit
−29.58%
−$2,958.28
Buy and hold
+102.5%
same period
Closed trades
61
13 won · 48 lost
Profitable
21.3%
of closed trades
Profit factor
0.66
gross profit ÷ gross loss
Max drawdown
50.14%
−$5,014.45

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.

  • Check

    2 settings do nothing

    “-----------------Strategy Inputs-------------------”, “-----------------General Inputs-------------------” are declared but never read.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    Uses an argument v6 removed

    when = on line 102, 103, 105, 106, 109, 110, 112, 113, 115, 116, 143, 144. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 85

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

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 lowest → ta.lowest, highest → ta.highest, valuewhen → ta.valuewhen, atr → ta.atr, rsi → ta.rsi, bb → ta.bb, crossover → ta.crossover, crossunder → ta.crossunder.
  • 12 strategy calls use the when = argument (line 102, 103, 105, 106, 109, 110, 112, 113, 115, 116, 143, 144). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 24: //@version=4 → //@version=5
  • Line 33: input(type = input.integer) → input.int()
  • Line 55: lowest → ta.lowest
  • Line 56: highest → ta.highest
  • Line 57: valuewhen → ta.valuewhen
  • Line 58: valuewhen → ta.valuewhen
14 more edits
  • Line 64: atr → ta.atr
  • Line 67: valuewhen → ta.valuewhen
  • Line 68: valuewhen → ta.valuewhen
  • Line 74: valuewhen → ta.valuewhen
  • Line 75: valuewhen → ta.valuewhen
  • Line 80: rsi → ta.rsi
  • Line 82: bb → ta.bb
  • Line 85: transp = 95 → color.new(color.blue, 95)
  • Line 87: bb → ta.bb
  • Line 90: transp = 95 → color.new(color.white, 95)
  • Line 91: crossover → ta.crossover
  • Line 92: crossunder → ta.crossunder
  • Line 123: valuewhen → ta.valuewhen
  • Line 135: valuewhen → ta.valuewhen
⋯// © tweakerID-//@version=4+//@version=5strategy("Double Bollinger Strategy", ⋯     slippage=0)-direction = input(0, title = "Strategy Direction", type=input.integer, minval=-1, maxval=1)+direction = input.int(0, title = "Strategy Direction", minval=-1, maxval=1)strategy.risk.allow_entry_in(direction == 0 ? strategy.direction.all : (direction < 0 ? strategy.direction.short : strategy.direction.long))⋯// Price Action Stop and Take Profit-LL=(lowest(i_SPL))*(1-i_PercIncrement)+LL=(ta.lowest(i_SPL))*(1-i_PercIncrement)-HH=(highest(i_SPL))*(1+i_PercIncrement)+HH=(ta.highest(i_SPL))*(1+i_PercIncrement)-LL_price = valuewhen(bought, LL, 0)+LL_price = ta.valuewhen(bought, LL, 0)-HH_price = valuewhen(bought, HH, 0)+HH_price = ta.valuewhen(bought, HH, 0)entry_LL_price = strategy.position_size > 0 ? LL_price : na ⋯// ATR Stop-ATR=atr(i_ATR)*i_ATRMult+ATR=ta.atr(i_ATR)*i_ATRMultATRLong = ohlc4 - ATRATRShort = ohlc4 + ATR-ATRLongStop = valuewhen(bought, ATRLong, 0)+ATRLongStop = ta.valuewhen(bought, ATRLong, 0)-ATRShortStop = valuewhen(bought, ATRShort, 0)+ATRShortStop = ta.valuewhen(bought, ATRShort, 0)LongSL_ATR_price = strategy.position_size > 0 ? ATRLongStop : na ⋯// Strategy Stop-float LongStop = valuewhen(bought,low[1],0)*(1-i_PercIncrement)+float LongStop = ta.valuewhen(bought,low[1],0)*(1-i_PercIncrement)-float ShortStop = valuewhen(bought,high[1],0)*(1+i_PercIncrement)+float ShortStop = ta.valuewhen(bought,high[1],0)*(1+i_PercIncrement)float StratTP = na⋯//RSI-RSI=rsi(close, i_RSI)+RSI=ta.rsi(close, i_RSI)//BOLL1-[middleS, upperS, lowerS] = bb(close, lengthS, 1)+[middleS, upperS, lowerS] = ta.bb(close, lengthS, 1)p1 = plot(upperS, "Slow BB Upper Band", color=color.teal)p2 = plot(lowerS, "Slow BB Lower Band", color=color.teal)-fill(p1, p2, title = "Slow BB Background", color=color.blue, transp=95)+fill(p1, p2, title = "Slow BB Background", color=color.new(color.blue, 95))//BOLL2-[middleF, upperF, lowerF] = bb(close, lengthF, 1)+[middleF, upperF, lowerF] = ta.bb(close, lengthF, 1)p1F = plot(upperF, "Fast BB Upper Band", color=color.gray)p2F = plot(lowerF, "Fast BB Lower Band", color=color.gray)-fill(p1F, p2F, title = "Fast BB Background", color=color.white, transp=95)+fill(p1F, p2F, title = "Fast BB Background", color=color.new(color.white, 95))-BUY = bar_index > 40 and (RSI > 50) and (close > upperF) and crossover(close, upperS)+BUY = bar_index > 40 and (RSI > 50) and (close > upperF) and ta.crossover(close, upperS)-SELL = bar_index > 40 and (RSI < 50) and (close < lowerF) and crossunder(close, lowerS) +SELL = bar_index > 40 and (RSI < 50) and (close < lowerF) and ta.crossunder(close, lowerS) longexit=close < upperF⋯//TrailingStop-dif=(valuewhen(strategy.position_size>0 and strategy.position_size[1]<=0, high,0))+dif=(ta.valuewhen(strategy.position_size>0 and strategy.position_size[1]<=0, high,0)) -strategy.position_avg_price⋯var Ststop = float(na)-Sdif=strategy.position_avg_price-(valuewhen(strategy.position_size<0 +Sdif=strategy.position_avg_price-(ta.valuewhen(strategy.position_size<0  and strategy.position_size[1]>=0, low,0))⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 36: input() → input.bool()
  • Line 37: input() → input.int()
  • Line 38: input() → input.int()
  • Line 39: input() → input.int()
  • Line 41: input() → input.bool()
  • Line 43: input() → input.bool()
22 more edits
  • Line 44: input() → input.string()
  • Line 45: input() → input.int()
  • Line 46: input() → input.int()
  • Line 47: input() → input.int()
  • Line 48: input() → input.int()
  • Line 49: input() → input.int()
  • Line 50: input() → input.bool()
  • Line 96: input() → input.bool()
  • Line 97: input() → input.bool()
  • Line 98: input() → input.bool()
  • Line 102: when = SELL and strategy.position_size == 0 → if block
  • Line 103: when = BUY and strategy.position_size == 0 → if block
  • Line 105: when = SELL → if block
  • Line 106: when = BUY → if block
  • Line 109: when = BUY and strategy.position_size == 0 → if block
  • Line 110: when = SELL and strategy.position_size == 0 → if block
  • Line 112: when = BUY → if block
  • Line 113: when = SELL → if block
  • Line 115: when = longexit → if block
  • Line 116: when = shortexit → if block
  • Line 143: when = i_SL → if block
  • Line 144: when = i_SL → if block
⋯/////////////////////// STRATEGY INPUTS ////////////////////////////////////////-title1=input(true, "-----------------Strategy Inputs-------------------")  +title1=input.bool(true, "-----------------Strategy Inputs-------------------")  -i_RSI=input(14, title="RSI Length")+i_RSI=input.int(14, title="RSI Length")-lengthS = input(45, minval=1, title="Slow BB Band Length")+lengthS = input.int(45, minval=1, title="Slow BB Band Length")-lengthF = input(31, minval=1, title="Fast BB Band Length")+lengthF = input.int(31, minval=1, title="Fast BB Band Length")/////////////////////// BACKTESTER /////////////////////////////////////////////-title2=input(true, "-----------------General Inputs-------------------")  +title2=input.bool(true, "-----------------General Inputs-------------------")  // Backtester General Inputs-i_SL=input(true, title="Use Stop Loss and Take Profit")+i_SL=input.bool(true, title="Use Stop Loss and Take Profit")-i_SLType=input(defval="Strategy Stop", title="Type Of Stop", options=["Strategy Stop", "Swing Lo/Hi", "ATR Stop"])+i_SLType=input.string(defval="Strategy Stop", title="Type Of Stop", options=["Strategy Stop", "Swing Lo/Hi", "ATR Stop"])-i_SPL=input(defval=10, title="Swing Point Lookback")+i_SPL=input.int(defval=10, title="Swing Point Lookback")-i_PercIncrement=input(defval=1, step=.1, title="Swing Point SL Perc Increment")*0.01+i_PercIncrement=input.int(defval=1, step=.1, title="Swing Point SL Perc Increment")*0.01-i_ATR = input(14, title="ATR Length")+i_ATR = input.int(14, title="ATR Length")-i_ATRMult = input(5, step=.1, title="ATR Multiple")+i_ATRMult = input.int(5, step=.1, title="ATR Multiple")-i_TPRRR = input(2, step=.1, title="Take Profit Risk Reward Ratio")+i_TPRRR = input.int(2, step=.1, title="Take Profit Risk Reward Ratio")-TS=input(false, title="Trailing Stop")+TS=input.bool(false, title="Trailing Stop")// Bought and Sold Boolean Signal⋯//Trading Inputs-i_strategyClose=input(true, title="Use Strategy Close Logic")+i_strategyClose=input.bool(true, title="Use Strategy Close Logic")-DPR=input(true, "Allow Direct Position Reverse")+DPR=input.bool(true, "Allow Direct Position Reverse")-reverse=input(false, "Reverse Trades")+reverse=input.bool(false, "Reverse Trades")// Entries⋯    if not DPR-        strategy.entry("long", strategy.long, when=SELL and strategy.position_size == 0)+        if SELL and strategy.position_size == 0+            strategy.entry("long", strategy.long)-        strategy.entry("short", strategy.short, when=BUY and strategy.position_size == 0)+        if BUY and strategy.position_size == 0+            strategy.entry("short", strategy.short)    else     -        strategy.entry("long", strategy.long, when=SELL)+        if SELL+            strategy.entry("long", strategy.long)-        strategy.entry("short", strategy.short, when=BUY)+        if BUY+            strategy.entry("short", strategy.short)else    if not DPR -        strategy.entry("long", strategy.long, when=BUY and strategy.position_size == 0)+        if BUY and strategy.position_size == 0+            strategy.entry("long", strategy.long)-        strategy.entry("short", strategy.short, when=SELL and strategy.position_size == 0)+        if SELL and strategy.position_size == 0+            strategy.entry("short", strategy.short)    else-        strategy.entry("long", strategy.long, when=BUY)+        if BUY+            strategy.entry("long", strategy.long)-        strategy.entry("short", strategy.short, when=SELL)+        if SELL+            strategy.entry("short", strategy.short)if i_strategyClose-    strategy.close("long", when=longexit)+    if longexit+        strategy.close("long")-    strategy.close("short", when=shortexit)+    if shortexit+        strategy.close("short")    ⋯    Ststop := na-strategy.exit("TP & SL", "long", limit=TP, stop=TS? tstop : SL, when=i_SL)+if i_SL+    strategy.exit("TP & SL", "long", limit=TP, stop=TS? tstop : SL)-strategy.exit("TP & SL", "short", limit=STP, stop=TS? Ststop : SSL, when=i_SL)+if i_SL+    strategy.exit("TP & SL", "short", limit=STP, stop=TS? Ststop : SSL)/////////////////////// PLOTS //////////////////////////////////////////////////⋯

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: 61 before, 22 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © tweakerID-//@version=5+//@version=6strategy("Double Bollinger Strategy", ⋯

Settings

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

SettingDefaultType and rangeFeeds
Strategy Direction0int (written input.integer) · min -1 · max 1line 34
-----------------Strategy Inputs-------------------trueboolunused
RSI Length14intRSI
Slow BB Band Length45int · min 1middleS upperS lowerS
Fast BB Band Length31int · min 1middleF upperF lowerF
-----------------General Inputs-------------------trueboolunused
Use Stop Loss and Take Profittrueboolexit TP & SL SL SSL TP STP
Type Of StopStrategy Stopstring · options ["Strategy Stop", "Swing Lo/Hi", "ATR Stop"]SL SSL TP STP
Swing Point Lookback10intLL HH
Swing Point SL Perc Increment1int · step .1LL HH LongStop ShortStop
ATR Length14intATR
ATR Multiple5int · step .1ATR
Take Profit Risk Reward Ratio2int · step .1tp stp ATRtp ATRstp
Trailing Stopfalseboolexit TP & SL SL SSL
Use Strategy Close Logictrueboolclose long close short line 114
Allow Direct Position Reversetrueboolentry long entry short entry long entry short entry long entry short entry long entry short line 101 line 108
Reverse Tradesfalseboolline 100

What it calculates

  • Lowest (lowest, ta.lowest in v5)Swing Point Lookback (10)LL · line 55
  • Highest (highest, ta.highest in v5)Swing Point Lookback (10)HH · line 56
  • Valuewhen (valuewhen, ta.valuewhen in v5)bought, LL, 0LL_price · line 57
  • Valuewhen (valuewhen, ta.valuewhen in v5)bought, HH, 0HH_price · line 58
  • ATR (atr, ta.atr in v5)ATR Length (14)ATR · line 64
  • Valuewhen (valuewhen, ta.valuewhen in v5)bought, ATRLong, 0ATRLongStop · line 67
  • Valuewhen (valuewhen, ta.valuewhen in v5)bought, ATRShort, 0ATRShortStop · line 68
  • Valuewhen (valuewhen, ta.valuewhen in v5)bought, low[1], 0LongStop · line 74
  • Valuewhen (valuewhen, ta.valuewhen in v5)bought, high[1], 0ShortStop · line 75
  • RSI (rsi, ta.rsi in v5)close, RSI Length (14)RSI · line 80
  • BB (bb, ta.bb in v5)close, Slow BB Band Length (45), 1middleS · line 82
  • BB (bb, ta.bb in v5)close, Slow BB Band Length (45), 1upperS · line 82
  • BB (bb, ta.bb in v5)close, Slow BB Band Length (45), 1lowerS · line 82
  • BB (bb, ta.bb in v5)close, Fast BB Band Length (31), 1middleF · line 87
  • BB (bb, ta.bb in v5)close, Fast BB Band Length (31), 1upperF · line 87
  • BB (bb, ta.bb in v5)close, Fast BB Band Length (31), 1lowerF · line 87

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.

The script has 71 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open long longSELL and strategy.position_size == 0On102
Open short shortBUY and strategy.position_size == 0On103
Open long longSELLbar_index > 40 and (RSI < 50) and (close < lowerF) and crossunder(close, lowerS)On105
Open short shortBUYbar_index > 40 and (RSI > 50) and (close > upperF) and crossover(close, upperS)On106
Open long longBUY and strategy.position_size == 0On109
Open short shortSELL and strategy.position_size == 0On110
Open long longBUYbar_index > 40 and (RSI > 50) and (close > upperF) and crossover(close, upperS)On112
Open short shortSELLbar_index > 40 and (RSI < 50) and (close < lowerF) and crossunder(close, lowerS)On113
Close longlongexitclose < upperFOn “Use Strategy Close Logic”115
Close shortshortexitclose > lowerFOn “Use Strategy Close Logic”116
Exit TP & SL stop and limiti_SLOn143
Exit TP & SL stop and limiti_SLOn144

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.

15/15trades 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−29.6%+102.5%6121%0.6650.1%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+3.2%+5.5%5018%1.0816.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+44.4%+9.8%4929%1.3229.9%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+14.4%+8.4%5422%1.2320.6%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−4.5%+16.7%5036%0.9645.3%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−1.2%+21.5%5018%0.9715.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−2.6%+148.3%4127%0.9623.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+7.1%+17.1%5231%1.229.3%8 May 2026 – 21 Oct 2026

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

Settings heatmap

Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (RSI Length 24, Slow BB Band Length 23) made −27.5% before 26 Dec 2025 and +5.6% after it, worse than the defaults' +14.4% after. Tuning on the past did not carry forward. 0% of the 64 combinations made money in-sample and 89% out-of-sample.

Before 26 Dec 2025 · in-sample
Slow BB Band Length ↓ · RSI Length →78101214172024
23−33%−33%−33%−33%−33%−33%−30%−27%
27−39%−39%−39%−39%−39%−39%−36%−34%
31−42%−42%−42%−42%−42%−42%−40%−35%
38−33%−33%−33%−33%−33%−33%−33%−33%
45−44%−44%−44%−44%−44%−44%−44%−44%
54−41%−41%−41%−41%−41%−41%−41%−41%
63−41%−41%−41%−41%−41%−41%−41%−41%
77−28%−28%−28%−28%−28%−28%−28%−28%
From 26 Dec 2025 · out-of-sample
Slow BB Band Length ↓ · RSI Length →78101214172024
23−2%−2%−2%−2%−2%−2%−1%+6%
27+11%+11%+11%+11%+11%+11%+12%+19%
31+6%+6%+6%+6%+6%+5%+6%+15%
38+11%+11%+11%+11%+11%+11%+12%+12%
45+14%+14%+14%+14%+14%+14%+14%+16%
54+23%+23%+23%+23%+23%+23%+23%+23%
63+26%+26%+26%+26%+26%+26%+26%+26%
77+27%+27%+27%+27%+27%+27%+27%+27%

Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market229%−$2,816.89
Sideways market2635%$231.78
Falling market1315%−$373.16

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

How bad could the drawdown be?

55.4%

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

0%64%
All 61 trades
SideEntryExitBarsP&L
long1 Apr 2024 71,280.002 Apr 2024 69,649.801−$236.52
long9 Apr 2024 71,620.0010 Apr 2024 69,146.001−$344.80
short14 Apr 2024 63,924.5015 Apr 2024 65,661.901−$263.51
short16 Apr 2024 63,420.0021 Apr 2024 64,940.605−$226.83
short25 Apr 2024 64,289.6026 Apr 2024 64,498.301−$36.13
short27 Apr 2024 63,770.0030 Apr 2024 63,866.003−$20.50
short1 May 2024 60,672.004 May 2024 62,882.003−$330.25
short11 May 2024 60,800.0013 May 2024 61,484.002−$102.92
long21 May 2024 71,446.6030 May 2024 67,652.409−$454.52
short23 Jun 2024 64,262.001 Jul 2024 62,772.008$178.74
long22 Jul 2024 68,165.4024 Jul 2024 65,119.202−$371.01
long27 Jul 2024 67,908.0031 Jul 2024 66,188.004−$203.43
short5 Aug 2024 58,161.008 Aug 2024 61,728.803−$471.56
short2 Sep 2024 57,301.802 Sep 2024 58,313.400−$131.34
short6 Sep 2024 56,180.0010 Sep 2024 57,042.004−$112.77
long19 Sep 2024 61,760.001 Oct 2024 63,327.6012$168.81
long15 Oct 2024 66,084.0024 Oct 2024 66,668.609$56.62
long12 Dec 2024 101,125.0019 Dec 2024 100,204.007−$70.27
short31 Dec 2024 92,792.102 Jan 2025 95,974.802−$246.67
long7 Jan 2025 102,236.008 Jan 2025 96,954.601−$355.42
short10 Jan 2025 92,552.5011 Jan 2025 94,726.101−$156.05
long18 Jan 2025 104,077.0027 Jan 2025 102,620.009−$92.74
long30 Jan 2025 103,733.001 Feb 2025 102,430.002−$82.51
short25 Feb 2025 91,552.903 Mar 2025 94,270.006−$185.74
short4 Mar 2025 86,221.206 Mar 2025 90,606.002−$305.22
short7 Apr 2025 78,430.0010 Apr 2025 82,615.203−$303.50
short11 Apr 2025 79,607.3012 Apr 2025 83,423.801−$258.33
long22 Apr 2025 87,516.2029 May 2025 107,782.0037$1,162.49
long10 Jun 2025 110,263.0012 Jun 2025 108,645.002−$95.92
short22 Jun 2025 102,120.0023 Jun 2025 105,022.001−$178.49
long3 Jul 2025 108,850.005 Jul 2025 107,984.002−$51.84
long7 Jul 2025 109,204.008 Jul 2025 108,263.001−$55.30
long9 Jul 2025 108,923.0026 Jul 2025 117,614.0017$459.57
long11 Aug 2025 119,294.0012 Aug 2025 118,686.001−$37.03
long13 Aug 2025 120,134.0015 Aug 2025 118,295.002−$100.52
short20 Aug 2025 112,873.0023 Aug 2025 116,936.003−$226.10
short25 Aug 2025 113,494.003 Sep 2025 111,240.009$112.79
short26 Sep 2025 108,994.0029 Sep 2025 112,164.003−$180.21
long2 Oct 2025 118,595.0010 Oct 2025 112,827.008−$289.02
short17 Oct 2025 108,194.0021 Oct 2025 110,532.004−$124.63
short22 Oct 2025 108,298.0024 Oct 2025 110,078.002−$93.75
short31 Oct 2025 108,323.001 Nov 2025 109,608.001−$67.67
short4 Nov 2025 106,583.0011 Nov 2025 106,011.007$24.09
short12 Nov 2025 103,059.0028 Nov 2025 91,333.9016$598.75
short16 Dec 2025 86,432.1017 Dec 2025 87,863.401−$102.40
short18 Dec 2025 86,243.2018 Dec 2025 89,057.700−$193.80
long5 Jan 2026 91,529.708 Jan 2026 91,364.203−$14.61
long14 Jan 2026 95,414.0020 Jan 2026 92,631.006−$167.33
short26 Jan 2026 86,670.4027 Jan 2026 88,347.101−$109.20
short30 Jan 2026 84,650.2021 Feb 2026 68,020.0022$1,039.24
long17 Mar 2026 74,884.7018 Mar 2026 71,547.701−$287.85
short28 Mar 2026 66,407.301 Apr 2026 68,284.504−$176.24
long8 Apr 2026 71,924.209 Apr 2026 71,069.901−$74.57
long14 Apr 2026 74,418.0029 Apr 2026 76,342.8015$145.56
long15 May 2026 81,090.0016 May 2026 79,113.201−$149.88
short28 May 2026 74,449.3015 Jun 2026 65,746.4018$674.26
long19 Jul 2026 64,834.2020 Jul 2026 63,247.801−$163.66
long27 Jul 2026 65,400.0027 Jul 2026 63,637.200−$175.22
short17 Aug 2026 62,900.0018 Aug 2026 64,532.101−$164.31
long20 Aug 2026 69,334.808 Sep 2026 79,112.0019$837.65
long19 Sep 2026 80,883.901 Oct 2026 83,623.6012$225.25

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
Double Bollinger Strategy this page—v4 strategy−29.6%6150.1%
Delayed RSI Strategy by tweakerIDlowest highest valuewhen atr rsiv4 strategy−40.4%742.2%
Positive Bars - Strategy by tweakerIDlowest highest valuewhen atrv4 strategy−40.3%754.7%
Big Bar Strategy by tweakerIDlowest highest valuewhen atrv4 strategy−56.6%1357.1%
SuperTrend Multi Time Frame Long and Short Trading Strategy by ranga_technologiesatr highest lowest valuewhenv5 strategyNo trades on this market
Dynamic Stop Loss Demo by Tindtilyhighest lowest rsi atrv5 strategydoes not run in Zeal Terminal

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 39 msYes 1,000 bars in 108 msNot measured
PineTSNo v5 and v6 only—Not measured

“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/// From "Bitcoin Trading Strategies: Algorithmic Trading Strategies For Bitcoin And Cryptocurrency That Work" by David Hanson.// "Double Bolinger Band Scalping System // Recommended Timeframe: 1 minute or 5 minute // Required Indicators: // - RSI with a length of 14 (default settings) // - Bolinger band #1 settings: Length = 50, stDev = 1 Hide the basis/middle line (basis line not needed for this strategy) // Note: This is the slower bolinger band in the directions // - Bolinger band #2 settings: Length 20, stDev = 1 Hide the basis/middle line (basis line not needed for this strategy) // Note: This is the faster bolinger band in the directions // Enter Long/Buy Trade When: // - RSI is above the level 50 // - A candle closes above the top of the faster bolinger band // Enter a long when a candle then closes above the top of the slower bolinger band, and price is above the top of both bands // Place a stop loss under the low of the entry candle Example of a long trade using this strategy // Exit Long Trade When: A candle closes below the top band of the fast bolinger band // Enter Short/Sell Trade When: // - RSI is below the level 50 // - A candle closes below the bottom of the faster bolinger band // Enter a short when a candle then closes below the bottom of the slower bolinger band, and price is below both bands // Place a stop loss above the high of the entry candle Example of a short trade using this strategy // Exit Short Trade When: Price closes inside the bottom of the faster bolinger band"// © tweakerID//@version=4strategy("Double Bollinger Strategy",      overlay=true,      default_qty_type=strategy.percent_of_equity,      default_qty_value=100,      initial_capital=10000,      commission_value=0.04,      calc_on_every_tick=false,      slippage=0)direction = input(0, title = "Strategy Direction", type=input.integer, minval=-1, maxval=1)strategy.risk.allow_entry_in(direction == 0 ? strategy.direction.all : (direction < 0 ? strategy.direction.short : strategy.direction.long))/////////////////////// STRATEGY INPUTS ////////////////////////////////////////title1=input(true, "-----------------Strategy Inputs-------------------")  i_RSI=input(14, title="RSI Length")lengthS = input(45, minval=1, title="Slow BB Band Length")lengthF = input(31, minval=1, title="Fast BB Band Length")/////////////////////// BACKTESTER /////////////////////////////////////////////title2=input(true, "-----------------General Inputs-------------------")  // Backtester General Inputsi_SL=input(true, title="Use Stop Loss and Take Profit")i_SLType=input(defval="Strategy Stop", title="Type Of Stop", options=["Strategy Stop", "Swing Lo/Hi", "ATR Stop"])i_SPL=input(defval=10, title="Swing Point Lookback")i_PercIncrement=input(defval=1, step=.1, title="Swing Point SL Perc Increment")*0.01i_ATR = input(14, title="ATR Length")i_ATRMult = input(5, step=.1, title="ATR Multiple")i_TPRRR = input(2, step=.1, title="Take Profit Risk Reward Ratio")TS=input(false, title="Trailing Stop")// Bought and Sold Boolean Signalbought = strategy.position_size > strategy.position_size[1]  or strategy.position_size < strategy.position_size[1]// Price Action Stop and Take ProfitLL=(lowest(i_SPL))*(1-i_PercIncrement)HH=(highest(i_SPL))*(1+i_PercIncrement)LL_price = valuewhen(bought, LL, 0)HH_price = valuewhen(bought, HH, 0)entry_LL_price = strategy.position_size > 0 ? LL_price : na entry_HH_price = strategy.position_size < 0 ? HH_price : na tp=strategy.position_avg_price + (strategy.position_avg_price - entry_LL_price)*i_TPRRRstp=strategy.position_avg_price - (entry_HH_price - strategy.position_avg_price)*i_TPRRR// ATR StopATR=atr(i_ATR)*i_ATRMultATRLong = ohlc4 - ATRATRShort = ohlc4 + ATRATRLongStop = valuewhen(bought, ATRLong, 0)ATRShortStop = valuewhen(bought, ATRShort, 0)LongSL_ATR_price = strategy.position_size > 0 ? ATRLongStop : na ShortSL_ATR_price = strategy.position_size < 0 ? ATRShortStop : na ATRtp=strategy.position_avg_price + (strategy.position_avg_price - LongSL_ATR_price)*i_TPRRRATRstp=strategy.position_avg_price - (ShortSL_ATR_price - strategy.position_avg_price)*i_TPRRR// Strategy Stopfloat LongStop = valuewhen(bought,low[1],0)*(1-i_PercIncrement)float ShortStop = valuewhen(bought,high[1],0)*(1+i_PercIncrement)float StratTP = nafloat StratSTP = na/////////////////////// STRATEGY LOGIC ///////////////////////////////////////////RSIRSI=rsi(close, i_RSI)//BOLL1[middleS, upperS, lowerS] = bb(close, lengthS, 1)p1 = plot(upperS, "Slow BB Upper Band", color=color.teal)p2 = plot(lowerS, "Slow BB Lower Band", color=color.teal)fill(p1, p2, title = "Slow BB Background", color=color.blue, transp=95)//BOLL2[middleF, upperF, lowerF] = bb(close, lengthF, 1)p1F = plot(upperF, "Fast BB Upper Band", color=color.gray)p2F = plot(lowerF, "Fast BB Lower Band", color=color.gray)fill(p1F, p2F, title = "Fast BB Background", color=color.white, transp=95)BUY = bar_index > 40 and (RSI > 50) and (close > upperF) and crossover(close, upperS)SELL = bar_index > 40 and (RSI < 50) and (close < lowerF) and crossunder(close, lowerS) longexit=close < upperFshortexit=close > lowerF//Trading Inputsi_strategyClose=input(true, title="Use Strategy Close Logic")DPR=input(true, "Allow Direct Position Reverse")reverse=input(false, "Reverse Trades")// Entriesif reverse    if not DPR        strategy.entry("long", strategy.long, when=SELL and strategy.position_size == 0)        strategy.entry("short", strategy.short, when=BUY and strategy.position_size == 0)    else             strategy.entry("long", strategy.long, when=SELL)        strategy.entry("short", strategy.short, when=BUY)else    if not DPR         strategy.entry("long", strategy.long, when=BUY and strategy.position_size == 0)        strategy.entry("short", strategy.short, when=SELL and strategy.position_size == 0)    else        strategy.entry("long", strategy.long, when=BUY)        strategy.entry("short", strategy.short, when=SELL)if i_strategyClose    strategy.close("long", when=longexit)    strategy.close("short", when=shortexit)    SL= i_SLType == "Swing Lo/Hi" ? entry_LL_price : i_SLType == "ATR Stop" ? LongSL_ATR_price : LongStopSSL= i_SLType == "Swing Lo/Hi" ? entry_HH_price : i_SLType == "ATR Stop" ? ShortSL_ATR_price : ShortStopTP= i_SLType == "Swing Lo/Hi" ? tp : i_SLType == "ATR Stop" ? ATRtp : StratTPSTP= i_SLType == "Swing Lo/Hi" ? stp : i_SLType == "ATR Stop" ? ATRstp : StratSTP//TrailingStopdif=(valuewhen(strategy.position_size>0 and strategy.position_size[1]<=0, high,0)) -strategy.position_avg_pricetrailOffset     = strategy.position_avg_price - SLvar tstop = float(na)if strategy.position_size > 0    tstop := high- trailOffset - dif    if tstop<tstop[1]        tstop:=tstop[1]else    tstop := naStrailOffset     = SSL - strategy.position_avg_pricevar Ststop = float(na)Sdif=strategy.position_avg_price-(valuewhen(strategy.position_size<0  and strategy.position_size[1]>=0, low,0))if strategy.position_size < 0    Ststop := low+ StrailOffset + Sdif    if Ststop>Ststop[1]        Ststop:=Ststop[1]else    Ststop := nastrategy.exit("TP & SL", "long", limit=TP, stop=TS? tstop : SL, when=i_SL)strategy.exit("TP & SL", "short", limit=STP, stop=TS? Ststop : SSL, when=i_SL)/////////////////////// PLOTS //////////////////////////////////////////////////plot(i_SL and strategy.position_size > 0 and not TS ? SL : i_SL and strategy.position_size > 0 and TS ? tstop : na , title='SL', style=plot.style_cross, color=color.red)plot(i_SL and strategy.position_size < 0 and not TS ? SSL : i_SL and strategy.position_size < 0 and TS ? Ststop : na , title='SSL', style=plot.style_cross, color=color.red)plot(i_SL and strategy.position_size > 0 ? TP : na, title='TP', style=plot.style_cross, color=color.green)plot(i_SL and strategy.position_size < 0 ? STP : na, title='STP', style=plot.style_cross, color=color.green)// Draw price action setup arrowsplotshape(BUY ? 1 : na, style=shape.triangleup, location=location.belowbar,  color=color.green, title="Bullish Setup", size=size.auto)plotshape(SELL ? 1 : na, style=shape.triangledown, location=location.abovebar,  color=color.red, title="Bearish Setup", size=size.auto)