Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

BB+RSI+OBV

A Pine Script v4 strategy built on CUM or Change, SMA (source, 20) and Stdev (source, 20). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 2 settings; defaults include Length 20 and Mult 2.0.

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 BB+RSI+OBV repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 21 of 21 trades.
How did BB+RSI+OBV do on BTCUSDT 1D with default settings?
+52.51%
From 26 Jan 2024 to 21 Oct 2026, over 71 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can BB+RSI+OBV be converted to Pine Script v5?
No
The automatic step from v4 to v5 gives a script that does not run in v5 (Pine Script v5 Error at @L20:C0: strategy.exit() must specify at least one of profit, limit, loss, stop, trail_price, trail_points, trail_offset. An exit ord…), so no v5 download is offered; the edits are shown below.
Does BB+RSI+OBV use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does BB+RSI+OBV run in Zeal Terminal?
Yes
It compiles in 12 ms and runs 1,000 bars in 31 ms, in the browser.

BTCUSDT · 1D · default settings

  • CUM
  • SMA
  • Stdev
  • 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 (2)
0.00100,000200,000AprJulOct2025AprJulOct2026AprJulOct$149,550$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference.
Net profit
+52.51%
$52,507.80
Buy and hold
+102.5%
same period
Closed trades
71
22 won · 49 lost
Profitable
31.0%
of closed trades
Profit factor
1.45
gross profit ÷ gross loss
Max drawdown
29.32%
−$32,288.30

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

    strategy.exit is used without a stop, loss or trailing stop.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Check

    strategy.exit with no exit price stops the upgrade to v5 line 20

    strategy.exit on line 20, 22 sets none of profit, limit, loss, stop or a trailing stop. v4 allows that; v5 rejects the call, so the script does not convert to v5 until each call gets one.

  • Note

    2 settings have no label

    In the settings dialog length (line 9), mult (line 10) show an empty name. The labels on this page come from the variable names.

  • 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 19, 20, 21, 22. The upgraded version below moves each call inside an if block.

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 cum → ta.cum, sign → math.sign, change → ta.change, sma → ta.sma, stdev → ta.stdev, rsi → ta.rsi.
  • 4 strategy calls use the when = argument (line 19, 20, 21, 22). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Differs

The v5 version does not run in Zeal Terminal's engine: Pine Script v5 Error at @L20:C0: strategy.exit() must specify at least one of profit, limit, loss, stop, trail_price, trail_points, trail_offset. An exit order with no condition can never fill.

  • Line 3: //@version=4 → //@version=5
  • Line 6: cum → ta.cum
  • Line 6: sign → math.sign
  • Line 6: change → ta.change
  • Line 11: sma → ta.sma
  • Line 12: stdev → ta.stdev
  • Line 15: rsi → ta.rsi
  • Line 17: rsi → ta.rsi
⋯// © atakhadivi-//@version=4+//@version=5strategy("BB+RSI+OBV", overlay=true)src = close-obv = cum(sign(change(src)) * volume)+obv = ta.cum(math.sign(ta.change(src)) * volume)// plot(obv, color=#3A6CA8, title="OnBalanceVolume")⋯mult = input(2.0, minval=0.001, maxval=50)-basis = sma(source, length)+basis = ta.sma(source, length)-dev = mult * stdev(source, length)+dev = mult * ta.stdev(source, length)upper = basis + devlower = basis - dev-buyEntry = source > basis and rsi(close, 14) > 50 and obv[1] < obv +buyEntry = source > basis and ta.rsi(close, 14) > 50 and obv[1] < obv buyExit = source < lower-sellEntry = source < basis and rsi(close, 14) < 50 and obv[1] > obv+sellEntry = source < basis and ta.rsi(close, 14) < 50 and obv[1] > obvsellExit = source > upper⋯

Clean v5

Not verified

The v5 script does not run in Zeal Terminal's engine (Pine Script v5 Error at @L20:C0: strategy.exit() must specify at least one of profit, limit, loss, stop, trail_price, trail_points, trail_offset. An exit order with no condition can never fill.), so this step could not be checked.

  • Line 9: input() → input.int()
  • Line 10: input() → input.float()
  • Line 19: when = buyEntry → if block
  • Line 20: when = buyExit → if block
  • Line 21: when = sellEntry → if block
  • Line 22: when = sellExit → if block
⋯source = close-length = input(20, minval=1)+length = input.int(20, minval=1)-mult = input(2.0, minval=0.001, maxval=50)+mult = input.float(2.0, minval=0.001, maxval=50)basis = ta.sma(source, length)⋯sellExit = source > upper-strategy.entry("BBandLE", strategy.long, stop=lower, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandLE", when=buyEntry)+if buyEntry+    strategy.entry("BBandLE", strategy.long, stop=lower, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandLE")-strategy.exit(id='BBandLE', when=buyExit)+if buyExit+    strategy.exit(id='BBandLE')-strategy.entry("BBandSE", strategy.short, stop=upper, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandSE", when=sellEntry)+if sellEntry+    strategy.entry("BBandSE", strategy.short, stop=upper, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandSE")-strategy.exit(id='BBandSE', when=sellExit)+if sellExit+    strategy.exit(id='BBandSE')

Does it run in Pine Script v6?

Not tested

The v5 script does not run in Zeal Terminal's engine (Pine Script v5 Error at @L22:C4: strategy.exit() must specify at least one of profit, limit, loss, stop, trail_price, trail_points, trail_offset. An exit order with no condition can never fill.), so this step could not be checked. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © atakhadivi-//@version=5+//@version=6strategy("BB+RSI+OBV", overlay=true)⋯

Settings

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

SettingDefaultType and rangeFeeds
Length (no label in the script)20int · min 1basis dev
Mult (no label in the script)2.0float · min 0.001 · max 50dev

What it calculates

  • CUM / Change (cum, ta.cum in v5)sign(change(src)) * volumeobv · line 6
  • SMA (sma, ta.sma in v5)source, Length (20)basis · line 11
  • Stdev (stdev, ta.stdev in v5)source, Length (20)dev · line 12

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.

volumevolumeprice datalengthLengthsetting · 20multMultsetting · 2.0closecloseprice dataobvCUM / Change→ obvbasisSMA→ basisdevStdev→ devsrc, sourcesrc · source2 valuesupper, lowerupper · lower2 valuesbuyEntrybuyEntryconditionbuyExitbuyExitconditionsellEntrysellEntryconditionsellExitsellExitconditionentry:BBandLEOpen BBandLEstrategy.entryexit:BBandLEexit BBandLEstrategy.exitentry:BBandSEOpen BBandSEstrategy.entryexit:BBandSEexit BBandSEstrategy.exit

Order rules

OrderFires whenBy defaultLine
Open BBandLE longbuyEntrysource > basis and rsi(close, 14) > 50 and obv[1] < obvOn19
Exit BBandLEbuyExitsource < lowerOn20
Open BBandSE shortsellEntrysource < basis and rsi(close, 14) < 50 and obv[1] > obvOn21
Exit BBandSEsellExitsource > upperOn22

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.

21/21trades 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+52.5%+102.5%7131%1.4529.3%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+1.6%+5.5%8226%1.0314.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+1.2%+9.8%6929%1.162.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.6%+8.4%10221%0.771.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.1%+16.7%7731%0.870.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%7831%1.370.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.4%+148.3%7130%1.390.4%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%8830%1.030.1%8 May 2026 – 21 Oct 2026

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

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market2730%−$32,010.60
Sideways market2741%$68,288.60
Falling market1718%$16,229.80

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

How bad could the drawdown be?

38.4%

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

0%44%
All 71 trades
SideEntryExitBarsP&L
long15 Feb 2024 51,795.2020 Mar 2024 61,937.4034$10,142.20
short20 Mar 2024 61,937.4021 Mar 2024 67,840.501−$5,903.10
long21 Mar 2024 67,840.5023 Mar 2024 63,796.602−$4,043.87
short23 Mar 2024 63,796.6026 Mar 2024 69,880.003−$6,083.36
long26 Mar 2024 69,880.003 Apr 2024 65,464.008−$4,416.01
short3 Apr 2024 65,464.005 Apr 2024 68,487.802−$3,023.81
long5 Apr 2024 68,487.8013 Apr 2024 67,116.508−$1,371.28
short13 Apr 2024 67,116.5023 Apr 2024 66,819.3010$297.20
long23 Apr 2024 66,819.3025 Apr 2024 64,289.602−$2,529.74
short25 Apr 2024 64,289.606 May 2024 64,012.0011$277.58
long6 May 2024 64,012.007 May 2024 63,165.201−$846.82
short7 May 2024 63,165.2016 May 2024 66,206.509−$3,041.33
long16 May 2024 66,206.5012 Jun 2024 67,314.2027$1,107.72
short12 Jun 2024 67,314.2015 Jul 2024 60,797.9033$6,516.32
long15 Jul 2024 60,797.901 Aug 2024 64,628.0017$3,830.10
short1 Aug 2024 64,628.0022 Aug 2024 61,156.0021$3,471.98
long22 Aug 2024 61,156.0028 Aug 2024 59,415.006−$1,741.03
short28 Aug 2024 59,415.0014 Sep 2024 60,498.0017−$1,082.99
long14 Sep 2024 60,498.002 Oct 2024 60,804.9018$306.93
short2 Oct 2024 60,804.9013 Oct 2024 63,206.2011−$2,401.31
long13 Oct 2024 63,206.2020 Dec 2024 97,461.9068$34,255.60
short20 Dec 2024 97,461.904 Jan 2025 98,174.2015−$712.31
long4 Jan 2025 98,174.209 Jan 2025 95,060.605−$3,113.56
short9 Jan 2025 95,060.6015 Jan 2025 96,560.906−$1,500.24
long15 Jan 2025 96,560.902 Feb 2025 100,636.0018$4,074.81
short2 Feb 2025 100,636.0021 Feb 2025 98,305.0019$2,330.65
long21 Feb 2025 98,305.0022 Feb 2025 96,182.001−$2,123.02
short22 Feb 2025 96,182.003 Mar 2025 94,270.009$1,912.00
long3 Mar 2025 94,270.004 Mar 2025 86,221.201−$8,048.83
short4 Mar 2025 86,221.2025 Mar 2025 87,498.2021−$1,277.00
long25 Mar 2025 87,498.2030 Mar 2025 82,648.505−$4,849.63
short30 Mar 2025 82,648.5012 Apr 2025 83,423.8013−$775.30
long12 Apr 2025 83,423.806 Jun 2025 101,509.0055$18,084.90
short6 Jun 2025 101,509.0010 Jun 2025 110,263.004−$8,754.33
long10 Jun 2025 110,263.0015 Jun 2025 105,415.005−$4,848.39
short15 Jun 2025 105,415.0017 Jun 2025 106,795.002−$1,379.90
long17 Jun 2025 106,795.0018 Jun 2025 104,551.001−$2,243.36
short18 Jun 2025 104,551.0024 Jun 2025 105,334.006−$782.77
long24 Jun 2025 105,334.001 Aug 2025 115,764.0038$10,430.10
short1 Aug 2025 115,764.008 Aug 2025 117,472.007−$1,707.95
long8 Aug 2025 117,472.0019 Aug 2025 116,227.0011−$1,244.97
short19 Aug 2025 116,227.0023 Aug 2025 116,936.004−$708.95
long23 Aug 2025 116,936.0024 Aug 2025 115,438.001−$1,497.94
short24 Aug 2025 115,438.0011 Sep 2025 113,960.0018$1,478.06
long11 Sep 2025 113,960.0023 Sep 2025 112,651.0012−$1,309.01
short23 Sep 2025 112,651.0030 Sep 2025 114,312.007−$1,660.98
long30 Sep 2025 114,312.0011 Oct 2025 112,774.0011−$1,537.48
short11 Oct 2025 112,774.0027 Oct 2025 114,559.0016−$1,784.92
long27 Oct 2025 114,559.0030 Oct 2025 110,021.003−$4,538.11
short30 Oct 2025 110,021.003 Jan 2026 89,995.1065$20,026.20
long3 Jan 2026 89,995.1021 Jan 2026 88,427.7018−$1,567.48
short21 Jan 2026 88,427.705 Mar 2026 72,666.8043$15,760.90
long5 Mar 2026 72,666.808 Mar 2026 67,262.903−$5,403.86
short8 Mar 2026 67,262.9011 Mar 2026 69,948.603−$2,685.73
long11 Mar 2026 69,948.6020 Mar 2026 69,930.009−$18.63
short20 Mar 2026 69,930.0024 Mar 2026 70,906.404−$976.44
long24 Mar 2026 70,906.4027 Mar 2026 68,820.303−$2,086.14
short27 Mar 2026 68,820.306 Apr 2026 69,034.2010−$213.87
long6 Apr 2026 69,034.2017 May 2026 78,148.1041$9,113.87
short17 May 2026 78,148.106 Jul 2026 63,650.0050$14,498.00
long6 Jul 2026 63,650.0025 Jul 2026 64,140.0019$489.99
short25 Jul 2026 64,140.0026 Jul 2026 64,375.001−$235.01
long26 Jul 2026 64,375.0028 Jul 2026 63,755.902−$619.15
short28 Jul 2026 63,755.9031 Jul 2026 64,780.003−$1,024.17
long31 Jul 2026 64,780.001 Aug 2026 62,887.901−$1,892.15
short1 Aug 2026 62,887.906 Aug 2026 64,665.205−$1,777.36
long6 Aug 2026 64,665.2011 Aug 2026 63,970.005−$695.23
short11 Aug 2026 63,970.0018 Aug 2026 64,532.107−$562.10
long18 Aug 2026 64,532.1016 Sep 2026 75,644.5029$11,112.40
short16 Sep 2026 75,644.5019 Sep 2026 80,883.903−$5,239.38
long19 Sep 2026 80,883.909 Oct 2026 81,754.5020$870.60

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
BB+RSI+OBV this page—v4 strategy+52.5%7129.3%
Crunchster's Normalised Trend Strategy by Crunchster1stdev cum smav5 strategy+22.9%7310.9%
meta-capitulation by serafimovklimentsma cumv5 strategyNo trades on this market
Double Bollinger Binary Options by Trade_by_DBsma stdevv5 strategyNo trades on this market
Improved Bollinger Swing Strategy Stock Nasdaq by exlux99sma stdevv4 strategy−20.4%722.3%
I11L Long Put-Call Ratio Inversion by I11Lsma stdevv5 strategyNo trades on this market

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 12 msYes 1,000 bars in 31 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/// © atakhadivi//@version=4strategy("BB+RSI+OBV", overlay=true)src = closeobv = cum(sign(change(src)) * volume)// plot(obv, color=#3A6CA8, title="OnBalanceVolume")source = closelength = input(20, minval=1)mult = input(2.0, minval=0.001, maxval=50)basis = sma(source, length)dev = mult * stdev(source, length)upper = basis + devlower = basis - devbuyEntry = source > basis and rsi(close, 14) > 50 and obv[1] < obv buyExit = source < lowersellEntry = source < basis and rsi(close, 14) < 50 and obv[1] > obvsellExit = source > upperstrategy.entry("BBandLE", strategy.long, stop=lower, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandLE", when=buyEntry)strategy.exit(id='BBandLE', when=buyExit)strategy.entry("BBandSE", strategy.short, stop=upper, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandSE", when=sellEntry)strategy.exit(id='BBandSE', when=sellExit)