Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Bollinger Bands and RSI Short Selling (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 stop loss and a profit target. Each trade commits 30% 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 Bollinger Bands and RSI Short Selling (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 Bollinger Bands and RSI Short Selling (by Coinrule) do on BTCUSDT 1D with default settings?
+7.62%
From 26 Jan 2024 to 21 Oct 2026, over 3 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Bollinger Bands and RSI Short Selling (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: 3 before, 3 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 Bollinger Bands and RSI Short Selling (by Coinrule) use a stop loss?
Yes
strategy.exit sets a stop on line 40.
Does Bollinger Bands and RSI Short Selling (by Coinrule) run in Zeal Terminal?
Yes
It compiles in 14 ms and runs 1,000 bars in 46 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$1,076$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 38) 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
+7.62%
$76.18
Buy and hold
+102.5%
same period
Closed trades
3
2 won · 1 lost
Profitable
66.7%
of closed trades
Profit factor
3.68
gross profit ÷ gross loss
Max drawdown
4.30%
−$42.99

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

    1 setting does nothing

    “Oversold” is declared but never read.

  • Note

    4 settings have no label

    In the settings dialog length (line 16), oversold (line 31), Stop_loss (line 33), Take_profit (line 34) 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 38. 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
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
Oversold (no label in the script)30intunused
Stop loss (no label in the script)1intshortStopPrice
Take profit (no label in the script)7intshortTakeProfit

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.0Stop_lossStop losssetting · 1Take_profitTake profitsetting · 7timetimeprice databasisSMA→ basisdevStdev→ devRSIRSI→ RSIupper, lowerupper · lower2 valuesshortStopPriceshortStopPricevalueshortTakeProfitshortTakeProfitvaluetimePeriodtimePeriodconditionnotInTradenotInTradeconditionentry: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 notInTradeOn38
Exit close stop and limit(ta.crossover(upper, close) and RSI > 70 and timePeriod)On40

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 1D+7.6%+102.5%367%3.684.3%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+1.6%+5.5%250%4.911.3%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+4.9%+9.8%540%1.4410.3%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−12.2%+8.4%50%0.0012.8%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+5.7%+16.7%333%1.9828.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−5.6%+21.5%333%0.4410.5%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−8.7%+148.3%425%0.4016.7%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−6.6%+17.1%617%0.167.7%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 market250%−$28.03
Sideways market1100%$104.21
Falling market0—$0.00

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

How bad could the drawdown be?

2.8%

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

0%3%
All 3 trades
SideEntryExitBarsP&L
short16 May 2024 66,206.5031 Oct 2024 72,344.80168−$28.41
short16 Dec 2024 104,464.0012 May 2025 104,118.00147$0.38
short14 Aug 2025 123,306.0025 Aug 2026 78,992.80376$104.21

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 Bands and RSI Short Selling (by Coinrule) this page—v5 strategy+7.6%34.3%
Bottom catch strategy by footlzsma stdev rsiv4 strategy+3.9%37.1%
Madri by Mdemoiorsi sma stdevv4 strategy+25.0%436.4%
Shorting when Bollinger Band Above Price with RSI (by Coinrule) by Coinrulesma stdev rsiv5 strategyNo trades on this market
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 38). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • 4 settings use the untyped input() (line 17, 31, 33, 34). 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 3 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 17: input() → input.source()
  • Line 31: input() → input.int()
  • Line 33: input() → input.int()
  • Line 34: input() → input.int()
  • Line 38: when = ta.crossover(close, upper) and RSI < 70 and timePeriod and notInTrade → if block
⋯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")⋯RSI = ta.rsi(close, lengthRSI)-oversold= input(30)+oversold= input.int(30)//Stop Loss and Take Profit for Shorting-Stop_loss= ((input (1))/100)+Stop_loss= ((input.int (1))/100)-Take_profit= ((input (7)/100))+Take_profit= ((input.int (7)/100))shortStopPrice  = strategy.position_avg_price * (1 + Stop_loss)⋯//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: 3 before, 3 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.

⋯// Works best on 30m, 45m timeframe-//@version=5+//@version=6strategy("Bollinger Bands and RSI Short Selling",⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 14 msWith a workaround 1,000 bars in 46 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 38) 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.

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/// © Coinrule// Works best on 30m, 45m timeframe//@version=5strategy("Bollinger Bands and RSI Short Selling",         overlay=true,         initial_capital = 1000,         default_qty_value = 30,         default_qty_type = strategy.percent_of_equity,         commission_type=strategy.commission.percent,         commission_value=0.1)//Backtest periodtimePeriod = time >= timestamp(syminfo.timezone, 2021, 12, 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)oversold= input(30)//Stop Loss and Take Profit for ShortingStop_loss= ((input (1))/100)Take_profit= ((input (7)/100))shortStopPrice  = strategy.position_avg_price * (1 + Stop_loss)shortTakeProfit = strategy.position_avg_price * (1 - Take_profit)//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', stop = shortTakeProfit, limit = shortStopPrice)