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
- 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Show Date Range | true | bool | unused |
| Length (no label in the script) | 20 | int · min 1 | basis dev |
| Source | close | source | basis dev |
| StdDev | 2.0 | float · min 0.001 · max 50 | dev |
| Offset | 0 | int · min -500 · max 500 | Upper Lower Basis |
| Trail Long Loss (%) | 3 | float · min 0.0 · step 0.1 | unused |
| Trail Short Loss (%) | 3 | float · min 0.0 · step 0.1 | shortStopPrice stopValue |
What it calculates
- SMASource (close), Length (20)
basis · line 19 - StdevSource (close), Length (20)
dev · line 20 - RSIclose, lengthRSI
RSI · 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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open short short | ta.crossover(close, upper) and RSI < 70 and timePeriod and notInTrade | On | 48 |
| Exit close limit | (ta.crossover(upper, close) and RSI > 70 and timePeriod) | On | 50 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −0.1% | +102.5% | 0 | 0% | 0.00 | 63.4% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −0.1% | +5.5% | 0 | 0% | 0.00 | 8.4% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +37.0% | +9.8% | 2 | 100% | 386.95 | 53.1% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.1% | +8.4% | 0 | 0% | 0.00 | 43.9% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +14.2% | +16.7% | 2 | 50% | 3.24 | 63.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.1% | +21.5% | 0 | 0% | 0.00 | 30.7% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −0.1% | +148.3% | 0 | 0% | 0.00 | 85.6% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +8.7% | +17.1% | 3 | 67% | 11.74 | 25.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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Shorting when Bollinger Band Above Price with RSI (by Coinrule) this page | — | v5 strategy | −0.1% | 0 | 63.4% |
| Bottom catch strategy by footlz | sma stdev rsi | v4 strategy | +3.9% | 3 | 7.1% |
| Madri by Mdemoio | rsi sma stdev | v4 strategy | +25.0% | 4 | 36.4% |
| Bollinger Bands and RSI Short Selling (by Coinrule) by Coinrule | sma stdev rsi | v5 strategy | +7.6% | 3 | 4.3% |
| RSI_Boll-TP-SL by BigCoinHunter | sma stdev rsi | v5 strategy | No trades on this market | ||
| FMC by oliverbadaoui | sma rsi stdev | v4 strategy | +139.5% | 44 | 111.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.
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
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 17 ms | With a workaround 1,000 bars in 36 ms | Not measured |
| PineTS | Not tested | Not tested | Not 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)