Pine Script v4 · Strategy
Bollinger Bands And Aroon Scalping (by Coinrule)
A Pine Script v4 strategy built on SMA (close, 20), Stdev (close, 20) and Highestbars (high, lengthAr+1). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 30% of equity and pays 0.1% commission. 14 settings; defaults include From Month 1, From Day 1 and From Year 2020.
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 Aroon Scalping (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 Aroon Scalping (by Coinrule) do on BTCUSDT 1D with default settings?
- −5.37%
- From 26 Jan 2024 to 21 Oct 2026, over 8 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Bollinger Bands And Aroon Scalping (by Coinrule) 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 Bollinger Bands And Aroon Scalping (by Coinrule) use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Bollinger Bands And Aroon Scalping (by Coinrule) run in Zeal Terminal?
- Yes
- It compiles in 12 ms and runs 1,000 bars in 38 ms, in the browser.
BTCUSDT · 1D · default settings
- SMA
- Stdev
- Highestbars
- Lowestbars
- Crossunder
- Crossunder
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −5.37%
- −$53.66
- Buy and hold
- +102.5%
- same period
- Closed trades
- 8
- 4 won · 4 lost
- Profitable
- 50.0%
- of closed trades
- Profit factor
- 0.54
- gross profit ÷ gross loss
- Max drawdown
- 10.05%
- −$103.28
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
2 settings do nothing
“Show Date Range”, “Offset” are declared but never read.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Note
2 settings have no label
In the settings dialog lengthBB (line 17), lengthAr (line 25) 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 33, 35. The upgraded version below moves each call inside an if block.
-
Note
Uses long =, which v5 renamed line 33
long = on line 33. v5 writes it as direction = strategy.long or strategy.short.
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 sma → ta.sma, stdev → ta.stdev, highestbars → ta.highestbars, lowestbars → ta.lowestbars, crossunder → ta.crossunder.
- 2 strategy calls use the when = argument (line 33, 35). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 8 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 6: input(type = input.integer) → input.int()
- Line 7: input(type = input.integer) → input.int()
- Line 8: input(type = input.integer) → input.int()
- Line 9: input(type = input.integer) → input.int()
- Line 10: input(type = input.integer) → input.int()
10 more edits
- Line 11: input(type = input.integer) → input.int()
- Line 12: input(type = input.bool) → input.bool()
- Line 20: sma → ta.sma
- Line 21: stdev → ta.stdev
- Line 24: input(type = input.integer) → input.int()
- Line 26: highestbars → ta.highestbars
- Line 27: lowestbars → ta.lowestbars
- Line 30: crossunder → ta.crossunder
- Line 31: crossunder → ta.crossunder
- Line 33: long = true → direction = strategy.long
⋯// © relevantLeader16058-//@version=4+//@version=5strategy(shorttitle='Bollinger bands And Aroon Scalping',title='Bollinger bands And Aroon Scalping (by Coinrule)', overlay=true, initial_capital = 1000, process_orders_on_close=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 30, commission_type=strategy.commission.percent, commission_value=0.1)//Backtest dates-fromMonth = input(defval = 1, title = "From Month", type = input.integer, minval = 1, maxval = 12)+fromMonth = input.int(defval = 1, title = "From Month", minval = 1, maxval = 12)-fromDay = input(defval = 1, title = "From Day", type = input.integer, minval = 1, maxval = 31)+fromDay = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)-fromYear = input(defval = 2020, title = "From Year", type = input.integer, minval = 1970)+fromYear = input.int(defval = 2020, title = "From Year", minval = 1970)-thruMonth = input(defval = 1, title = "Thru Month", type = input.integer, minval = 1, maxval = 12)+thruMonth = input.int(defval = 1, title = "Thru Month", minval = 1, maxval = 12)-thruDay = input(defval = 1, title = "Thru Day", type = input.integer, minval = 1, maxval = 31)+thruDay = input.int(defval = 1, title = "Thru Day", minval = 1, maxval = 31)-thruYear = input(defval = 2112, title = "Thru Year", type = input.integer, minval = 1970)+thruYear = input.int(defval = 2112, title = "Thru Year", minval = 1970)-showDate = input(defval = true, title = "Show Date Range", type = input.bool)+showDate = input.bool(defval = true, title = "Show Date Range")start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start window⋯mult = input(2.0, minval=0.001, maxval=50, title="StdDev")-basis = sma(src, lengthBB)+basis = ta.sma(src, lengthBB)-dev = mult * stdev(src, lengthBB)+dev = mult * ta.stdev(src, lengthBB)upper = basis + devlower = basis - dev-offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)+offset = input.int(0, "Offset", minval = -500, maxval = 500)lengthAr = input(288, minval=1)-AroonUP = 100 * (highestbars(high, lengthAr+1) + lengthAr)/lengthAr+AroonUP = 100 * (ta.highestbars(high, lengthAr+1) + lengthAr)/lengthAr-AroonDown = 100 * (lowestbars(low, lengthAr+1) + lengthAr)/lengthAr+AroonDown = 100 * (ta.lowestbars(low, lengthAr+1) + lengthAr)/lengthArConfirmation = input(90, "Aroon Confirmation")Stop = input(70, "Aroon Stop")-Bullish = crossunder (close, basis)+Bullish = ta.crossunder (close, basis)-Bearish = crossunder (close, upper)+Bearish = ta.crossunder (close, upper)//Entry -strategy.entry(id="long", long = true, when = Bullish and AroonUP > Confirmation and window())+strategy.entry(id="long", direction = strategy.long, when = Bullish and AroonUP > Confirmation and window())//Exit⋯Same 8 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 17: input() → input.int()
- Line 18: input() → input.source()
- Line 19: input() → input.float()
- Line 25: input() → input.int()
- Line 28: input() → input.int()
- Line 29: input() → input.int()
- Line 33: when = Bullish and AroonUP > Confirmation and window() → if block
- Line 35: when = Bearish or AroonUP < Stop and window() → if block
⋯// BB inputs and calculations-lengthBB = input(20, minval=1)+lengthBB = input.int(20, minval=1)-src = input(close, title="Source")+src = input.source(close, title="Source")-mult = input(2.0, minval=0.001, maxval=50, title="StdDev")+mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")basis = ta.sma(src, lengthBB)⋯offset = input.int(0, "Offset", minval = -500, maxval = 500)-lengthAr = input(288, minval=1)+lengthAr = input.int(288, minval=1)AroonUP = 100 * (ta.highestbars(high, lengthAr+1) + lengthAr)/lengthArAroonDown = 100 * (ta.lowestbars(low, lengthAr+1) + lengthAr)/lengthAr-Confirmation = input(90, "Aroon Confirmation")+Confirmation = input.int(90, "Aroon Confirmation")-Stop = input(70, "Aroon Stop")+Stop = input.int(70, "Aroon Stop")Bullish = ta.crossunder (close, basis)⋯//Entry -strategy.entry(id="long", direction = strategy.long, when = Bullish and AroonUP > Confirmation and window())+if Bullish and AroonUP > Confirmation and window()+ strategy.entry(id="long", direction = strategy.long)//Exit-strategy.close("long", when = Bearish or AroonUP < Stop and window())+if Bearish or AroonUP < Stop and window()+ strategy.close("long")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: 8 before, 8 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.
⋯// © relevantLeader16058-//@version=5+//@version=6strategy(shorttitle='Bollinger bands And Aroon Scalping',title='Bollinger bands And Aroon Scalping (by Coinrule)', overlay=true, initial_capital = 1000, process_orders_on_close=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 30, commission_type=strategy.commission.percent, commission_value=0.1)⋯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 |
|---|---|---|---|
| From Month | 1 | int (written input.integer) · min 1 · max 12 | start |
| From Day | 1 | int (written input.integer) · min 1 · max 31 | start |
| From Year | 2020 | int (written input.integer) · min 1970 | start |
| Thru Month | 1 | int (written input.integer) · min 1 · max 12 | finish |
| Thru Day | 1 | int (written input.integer) · min 1 · max 31 | finish |
| Thru Year | 2112 | int (written input.integer) · min 1970 | finish |
| Show Date Range | true | bool | unused |
| Length BB (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 (written input.integer) · min -500 · max 500 | unused |
| Length Ar (no label in the script) | 288 | int · min 1 | AroonUP AroonDown |
| Aroon Confirmation | 90 | int | entry long |
| Aroon Stop | 70 | int | close long |
What it calculates
- SMA (
sma,ta.smain v5)Source (close), Length BB (20)basis · line 20 - Stdev (
stdev,ta.stdevin v5)Source (close), Length BB (20)dev · line 21 - Highestbars (
highestbars,ta.highestbarsin v5)high, lengthAr+1AroonUP · line 26 - Lowestbars (
lowestbars,ta.lowestbarsin v5)low, lengthAr+1AroonDown · line 27 - Crossunder (
crossunder,ta.crossunderin v5)close, basisBullish · line 30 - Crossunder (
crossunder,ta.crossunderin v5)close, upperBearish · line 31
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 long long | Bullish and AroonUP > Confirmation and window() | On | 33 |
| Close long | Bearish or AroonUP < Stop and window() | On | 35 |
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 | −5.4% | +102.5% | 8 | 50% | 0.54 | 10.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +1.0% | +5.5% | 4 | 75% | 2.21 | 1.4% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −16.7% | +9.8% | 3 | 33% | 0.08 | 17.6% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +4.0% | +8.4% | 6 | 100% | — | 1.5% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −9.7% | +16.7% | 2 | 50% | 0.18 | 16.6% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +3.2% | +21.5% | 4 | 75% | 113.66 | 2.2% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +6.8% | +148.3% | 5 | 60% | 1.62 | 9.3% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +3.7% | +17.1% | 7 | 86% | 2.57 | 2.9% | 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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 6 | 67% | $12.62 |
| Sideways market | 2 | 0% | −$66.28 |
| Falling market | 0 | — | $0.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
11.2%
The 95th percentile of the worst drawdown when the same 8 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 6.4% to 11.2%; the tick is what actually happened, 7.9%. Order luck alone moves it this much.
All 8 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 10 Dec 2024 96,593.00 | 18 Dec 2024 100,204.00 | 8 | $10.59 |
| long | 19 Dec 2024 97,461.90 | 7 Jan 2025 96,954.60 | 19 | −$2.18 |
| long | 8 Jan 2025 95,060.60 | 19 Jan 2025 101,332.00 | 11 | $19.31 |
| long | 1 Feb 2025 100,636.00 | 17 Apr 2025 84,947.90 | 75 | −$48.58 |
| long | 29 May 2025 105,590.00 | 15 Jul 2025 117,758.00 | 47 | $33.20 |
| long | 29 Jul 2025 117,951.00 | 14 Aug 2025 118,295.00 | 16 | $0.28 |
| long | 18 Aug 2025 116,227.00 | 13 Sep 2025 115,918.00 | 26 | −$1.41 |
| long | 10 Oct 2025 112,775.00 | 1 Jan 2026 88,839.00 | 83 | −$64.86 |
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 |
|---|---|---|---|---|---|
| Bollinger Bands And Aroon Scalping (by Coinrule) this page | — | v4 strategy | −5.4% | 8 | 10.0% |
| Configurable BB+RSI+Aroon strategy backtest for binary options by MarcoJarquin | highestbars lowestbars sma stdev | v5 strategy | No trades on this market | ||
| Double Bollinger Binary Options by Trade_by_DB | sma stdev | v5 strategy | No trades on this market | ||
| Improved Bollinger Swing Strategy Stock Nasdaq by exlux99 | sma stdev | v4 strategy | −20.4% | 7 | 22.3% |
| I11L Long Put-Call Ratio Inversion by I11L | sma stdev | v5 strategy | No trades on this market | ||
| P-Signal Strategy by Kharevsky | stdev sma | v4 strategy | −9.7% | 29 | 34.6% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 12 ms | With a workaround 1,000 bars in 38 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 33) 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. 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/// © relevantLeader16058//@version=4strategy(shorttitle='Bollinger bands And Aroon Scalping',title='Bollinger bands And Aroon Scalping (by Coinrule)', overlay=true, initial_capital = 1000, process_orders_on_close=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 30, commission_type=strategy.commission.percent, commission_value=0.1)//Backtest datesfromMonth = input(defval = 1, title = "From Month", type = input.integer, minval = 1, maxval = 12)fromDay = input(defval = 1, title = "From Day", type = input.integer, minval = 1, maxval = 31)fromYear = input(defval = 2020, title = "From Year", type = input.integer, minval = 1970)thruMonth = input(defval = 1, title = "Thru Month", type = input.integer, minval = 1, maxval = 12)thruDay = input(defval = 1, title = "Thru Day", type = input.integer, minval = 1, maxval = 31)thruYear = input(defval = 2112, title = "Thru Year", type = input.integer, minval = 1970)showDate = input(defval = true, title = "Show Date Range", type = input.bool)start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start windowfinish = timestamp(thruYear, thruMonth, thruDay, 23, 59) // backtest finish windowwindow() => time >= start and time <= finish ? true : false // create function "within window of time"// BB inputs and calculationslengthBB = input(20, minval=1)src = input(close, title="Source")mult = input(2.0, minval=0.001, maxval=50, title="StdDev")basis = sma(src, lengthBB)dev = mult * stdev(src, lengthBB)upper = basis + devlower = basis - devoffset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)lengthAr = input(288, minval=1)AroonUP = 100 * (highestbars(high, lengthAr+1) + lengthAr)/lengthArAroonDown = 100 * (lowestbars(low, lengthAr+1) + lengthAr)/lengthArConfirmation = input(90, "Aroon Confirmation")Stop = input(70, "Aroon Stop")Bullish = crossunder (close, basis)Bearish = crossunder (close, upper)//Entry strategy.entry(id="long", long = true, when = Bullish and AroonUP > Confirmation and window())//Exitstrategy.close("long", when = Bearish or AroonUP < Stop and window())