Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Shorting when Bollinger Band Above Price with RSI (by Coinrule)

A Pine Script v5 strategy built on SMA (close, 20), Stdev (close, 20) and RSI (close, lengthRSI). It has 2 order rules, 1 entry among them, and trades short only with the default settings. Exits use a profit target and no stop loss. Each trade commits 70% of equity and pays 0.1% commission. 7 settings; defaults include Length 20, Source close and StdDev 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 Shorting when Bollinger Band Above Price with RSI (by Coinrule) repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Shorting when Bollinger Band Above Price with RSI (by Coinrule) 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 short position that was still open on the last bar, so there is no result to report. Its code limits trading to a date window, which can leave this period out. On ETHUSDT 1D it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
Does Shorting when Bollinger Band Above Price with RSI (by Coinrule) 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: 0 before, 2 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does Shorting when Bollinger Band Above Price with RSI (by Coinrule) use a stop loss?
No
Its exits set a profit target but no stop.
Does Shorting when Bollinger Band Above Price with RSI (by Coinrule) run in Zeal Terminal?
Yes
It compiles in 17 ms and runs 1,000 bars in 36 ms, in the browser.

BTCUSDT · 1D · default settings

  • Basis
  • Upper
  • Lower
  • 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 (7)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$804$2,025Equity from $1,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 direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 48) so the engine trades the way the script says.
Net profit
−0.07%
−$0.70
Buy and hold
+102.5%
same period
Closed trades
0
0 won · 0 lost
Profitable
0.0%
of closed trades
Profit factor
0.00
gross profit ÷ gross loss
Max drawdown
63.44%
−$634.37

One run with the author's default settings, $1,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

    2 settings do nothing

    “Show Date Range”, “Trail Long Loss (%)” are declared but never read.

  • Check

    No stop loss

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

  • Note

    1 setting has no label

    In the settings dialog length (line 16) shows 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 48. The upgraded version below moves each call inside an if block.

Settings

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

SettingDefaultType and rangeFeeds
Show Date Rangetrueboolunused
Length (no label in the script)20int · min 1basis dev
Sourceclosesourcebasis dev
StdDev2.0float · min 0.001 · max 50dev
Offset0int · min -500 · max 500Upper Lower Basis
Trail Long Loss (%)3float · min 0.0 · step 0.1unused
Trail Short Loss (%)3float · min 0.0 · step 0.1shortStopPrice stopValue

What it calculates

  • SMASource (close), Length (20)basis · line 19
  • StdevSource (close), Length (20)dev · line 20
  • RSIclose, lengthRSIRSI · line 30

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 datalengthLengthsetting · 20multStdDevsetting · 2.0shortTrailPercTrail Short Loss (%)setting · 3timetimeprice databasisSMA→ basisdevStdev→ devRSIRSI→ RSIupper, lowerupper · lower2 valuesstopValuestopValuevaluetimePeriodtimePeriodconditionnotInTradenotInTradeconditionshortStopPriceshortStopPriceconditionentry:shortOpen shortstrategy.entryexit:closeexit closestrategy.exitplot:24Basisplotplot:25Upperplotplot:26Lowerplotfill:BackgroundBackgroundfill

Order rules

OrderFires whenBy defaultLine
Open short shortta.crossover(close, upper) and RSI < 70 and timePeriod and notInTradeOn48
Exit close limit(ta.crossover(upper, close) and RSI > 70 and timePeriod)On50

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 timingprocess_orders_on_close = true: orders fill at the signal bar's close.

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−0.1%+102.5%00%0.0063.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.1%+5.5%00%0.008.4%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+37.0%+9.8%2100%386.9553.1%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.1%+8.4%00%0.0043.9%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+14.2%+16.7%250%3.2463.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.1%+21.5%00%0.0030.7%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.1%+148.3%00%0.0085.6%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+8.7%+17.1%367%11.7425.0%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
Shorting when Bollinger Band Above Price with RSI (by Coinrule) this page—v5 strategy−0.1%063.4%
Bottom catch strategy by footlzsma stdev rsiv4 strategy+3.9%37.1%
Madri by Mdemoiorsi sma stdevv4 strategy+25.0%436.4%
Bollinger Bands and RSI Short Selling (by Coinrule) by Coinrulesma stdev rsiv5 strategy+7.6%34.3%
RSI_Boll-TP-SL by BigCoinHuntersma stdev rsiv5 strategyNo trades on this market
FMC by oliverbadaouisma rsi stdevv4 strategy+139.5%44111.9%

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • 1 strategy call uses the when = argument (line 48). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • 2 settings use the untyped input() (line 12, 17). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

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

  • Line 12: input() → input.bool()
  • Line 17: input() → input.source()
  • Line 48: when = ta.crossover(close, upper) and RSI < 70 and timePeriod and notInTrade → if block
⋯         commission_value=0.1)-showDate = input(defval=true, title='Show Date Range')+showDate = input.bool(defval=true, title='Show Date Range')timePeriod = time >= timestamp(syminfo.timezone, 2022, 1, 1, 0, 0)⋯length = input.int(20, minval=1)-src = input(close, title="Source")+src = input.source(close, title="Source")mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")⋯//Entry and Exit-strategy.entry(id="short", direction=strategy.short, when=ta.crossover(close, upper) and RSI < 70 and timePeriod and notInTrade)+if ta.crossover(close, upper) and RSI < 70 and timePeriod and notInTrade+    strategy.entry(id="short", direction=strategy.short)if (ta.crossover(upper, close) and RSI > 70 and timePeriod)⋯

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: 0 before, 2 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.

-//@version=5+//@version=6// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 17 msWith a workaround 1,000 bars in 36 msNot measured
PineTSNot testedNot testedNot measured

Zeal Terminal's engine currently reads an order side written as direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 48) 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.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

//@version=5// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © Coinrulestrategy("Bollinger Band Below Price with RSI",         overlay=true,         initial_capital=1000,         process_orders_on_close=true,         default_qty_type=strategy.percent_of_equity,         default_qty_value=70,         commission_type=strategy.commission.percent,         commission_value=0.1)showDate = input(defval=true, title='Show Date Range')timePeriod = time >= timestamp(syminfo.timezone, 2022, 1, 1, 0, 0)notInTrade = strategy.position_size <= 0//Bollinger Bands Indicatorlength = input.int(20, minval=1)src = input(close, title="Source")mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")basis = ta.sma(src, length)dev = mult * ta.stdev(src, length)upper = basis + devlower = basis - devoffset = input.int(0, "Offset", minval = -500, maxval = 500)plot(basis, "Basis", color=#FF6D00, offset = offset)p1 = plot(upper, "Upper", color=#2962FF, offset = offset)p2 = plot(lower, "Lower", color=#2962FF, offset = offset)fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))// RSI inputs and calculationslengthRSI = 14RSI = ta.rsi(close, lengthRSI)// Configure trail stop level with input optionslongTrailPerc = input.float(title='Trail Long Loss (%)', minval=0.0, step=0.1, defval=3) * 0.01shortTrailPerc = input.float(title='Trail Short Loss (%)', minval=0.0, step=0.1, defval=3) * 0.01// Determine trail stop loss prices//longStopPrice = 0.0shortStopPrice = 0.0//longStopPrice := if strategy.position_size > 0    //stopValue = close * (1 - longTrailPerc)    //math.max(stopValue, longStopPrice[1])//else    //0shortStopPrice := if strategy.position_size < 0    stopValue = close * (1 + shortTrailPerc)    math.min(stopValue, shortStopPrice[1])else    999999//Entry and Exitstrategy.entry(id="short", direction=strategy.short, when=ta.crossover(close, upper) and RSI < 70 and timePeriod and notInTrade)if (ta.crossover(upper, close) and RSI > 70 and timePeriod)    strategy.exit(id='close', limit = shortStopPrice)