Pine Script v4 · Strategy
Forex Scalping 1min Bollinger Bands, RSI and ADX Trading System
A Pine Script v4 strategy built on RSI (price, 20), Crossover (vrsi, 35) and Crossunder (vrsi, 65). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 10 settings; defaults include Length 20, Over Sold 35 and Over Bought 65.
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 Forex Scalping 1min Bollinger Bands, RSI and ADX Trading System repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did Forex Scalping 1min Bollinger Bands, RSI and ADX Trading System do on BTCUSDT 1D with default settings?
- −0.00%
- From 26 Jan 2024 to 21 Oct 2026, over 3 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Forex Scalping 1min Bollinger Bands, RSI and ADX Trading System 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 Forex Scalping 1min Bollinger Bands, RSI and ADX Trading System use a stop loss?
- Yes
- strategy.exit sets a stop on line 47, 50.
- Does Forex Scalping 1min Bollinger Bands, RSI and ADX Trading System run in Zeal Terminal?
- Yes
- It compiles in 16 ms and runs 1,000 bars in 47 ms, in the browser.
BTCUSDT · 1D · default settings
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −0.00%
- −$0.90
- Buy and hold
- +102.5%
- same period
- Closed trades
- 3
- 1 won · 2 lost
- Profitable
- 33.3%
- of closed trades
- Profit factor
- 0.50
- gross profit ÷ gross loss
- Max drawdown
- 0.00%
- −$1.80
One run with the author's default settings, $100,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
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
6 settings have no label
In the settings dialog length (line 9), overSold (line 10), overBought (line 11), lengthB (line 18), tp (line 44), sl (line 45) 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 46, 48, 49, 51. 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 rsi → ta.rsi, crossover → ta.crossover, crossunder → ta.crossunder, sma → ta.sma, stdev → ta.stdev, change → ta.change, rma → ta.rma, abs → math.abs.
- 4 strategy calls use the when = argument (line 46, 48, 49, 51). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 3 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 13: rsi → ta.rsi
- Line 14: crossover → ta.crossover
- Line 15: crossunder → ta.crossunder
- Line 21: sma → ta.sma
- Line 22: stdev → ta.stdev
14 more edits
- Line 29: change → ta.change
- Line 30: change → ta.change
- Line 33: rma → ta.rma
- Line 33: tr → ta.tr
- Line 34: rma → ta.rma
- Line 35: rma → ta.rma
- Line 40: rma → ta.rma
- Line 40: abs → math.abs
- Line 42: crossover → ta.crossover
- Line 43: crossunder → ta.crossunder
- Line 46: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
- Line 48: crossunder → ta.crossunder
- Line 49: strategy.entry(…, 0) → strategy.entry(…, strategy.short)
- Line 51: crossover → ta.crossover
⋯// © exlux99-//@version=4+//@version=5strategy("Bollinger Bands, RSI and ADX Trading System", overlay=true)⋯price = close-vrsi = rsi(price, length)+vrsi = ta.rsi(price, length)-co = crossover(vrsi, overSold)+co = ta.crossover(vrsi, overSold)-cu = crossunder(vrsi, overBought)+cu = ta.crossunder(vrsi, overBought)//if (not na(vrsi))⋯mult = input(2.0, minval=0.001, maxval=50, title="StdDev")-basis = sma(src, lengthB)+basis = ta.sma(src, lengthB)-dev = mult * stdev(src, lengthB)+dev = mult * ta.stdev(src, lengthB)upper = basis + dev⋯dirmov(len) =>- up = change(high)+ up = ta.change(high)- down = -change(low)+ down = -ta.change(low) plusDM = na(up) ? na : (up > down and up > 0 ? up : 0) minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)- truerange = rma(tr, len)+ truerange = ta.rma(ta.tr, len)- plus = fixnan(100 * rma(plusDM, len) / truerange)+ plus = fixnan(100 * ta.rma(plusDM, len) / truerange)- minus = fixnan(100 * rma(minusDM, len) / truerange)+ minus = fixnan(100 * ta.rma(minusDM, len) / truerange) [plus, minus]⋯ sum = plus + minus- adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)+ adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)sig = adx(dilen, adxlen)-longEntry = close < upper and crossover(vrsi,overSold) and sig < 32 //and (timeinrange(timeframe.period, "0301-0600") or timeinrange(timeframe.period, "0901-1300") or timeinrange(timeframe.period, "2031-2300"))+longEntry = close < upper and ta.crossover(vrsi,overSold) and sig < 32 //and (timeinrange(timeframe.period, "0301-0600") or timeinrange(timeframe.period, "0901-1300") or timeinrange(timeframe.period, "2031-2300"))-shortEntry = close > upper and crossunder(vrsi,overBought) and sig < 32 //and (timeinrange(timeframe.period, "0301-0600") or timeinrange(timeframe.period, "0901-1300") or timeinrange(timeframe.period, "2031-2300"))+shortEntry = close > upper and ta.crossunder(vrsi,overBought) and sig < 32 //and (timeinrange(timeframe.period, "0301-0600") or timeinrange(timeframe.period, "0901-1300") or timeinrange(timeframe.period, "2031-2300"))tp=input(90, step=10)sl=input(90, step=10)-strategy.entry("long",1,when=longEntry)+strategy.entry("long",strategy.long,when=longEntry)strategy.exit("X_long", "long", profit=tp, loss=sl )-strategy.close("long",when=crossunder(close,basis))+strategy.close("long",when=ta.crossunder(close,basis))-strategy.entry('short',0,when=shortEntry)+strategy.entry('short',strategy.short,when=shortEntry)strategy.exit("x_short", "short",profit=tp, loss=sl)-strategy.close("short",when=crossover(close,basis))+strategy.close("short",when=ta.crossover(close,basis))Same 3 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 9: input() → input.int()
- Line 10: input() → input.int()
- Line 11: input() → input.int()
- Line 18: input() → input.int()
- Line 19: input() → input.source()
- Line 20: input() → input.float()
8 more edits
- Line 26: input() → input.int()
- Line 27: input() → input.int()
- Line 44: input() → input.int()
- Line 45: input() → input.int()
- Line 46: when = longEntry → if block
- Line 48: when = ta.crossunder(close,basis) → if block
- Line 49: when = shortEntry → if block
- Line 51: when = ta.crossover(close,basis) → if block
⋯//RSI-length = input( 20 )+length = input.int( 20 )-overSold = input( 35 )+overSold = input.int( 35 )-overBought = input( 65 )+overBought = input.int( 65 )price = close⋯//BB-lengthB = input(60, minval=1)+lengthB = input.int(60, 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, lengthB)⋯//adx-adxlen = input(14, title="ADX Smoothing")+adxlen = input.int(14, title="ADX Smoothing")-dilen = input(14, title="DI Length")+dilen = input.int(14, title="DI Length")dirmov(len) =>⋯shortEntry = close > upper and ta.crossunder(vrsi,overBought) and sig < 32 //and (timeinrange(timeframe.period, "0301-0600") or timeinrange(timeframe.period, "0901-1300") or timeinrange(timeframe.period, "2031-2300"))-tp=input(90, step=10)+tp=input.int(90, step=10)-sl=input(90, step=10)+sl=input.int(90, step=10)-strategy.entry("long",strategy.long,when=longEntry)+if longEntry+ strategy.entry("long",strategy.long)strategy.exit("X_long", "long", profit=tp, loss=sl )-strategy.close("long",when=ta.crossunder(close,basis))+if ta.crossunder(close,basis)+ strategy.close("long")-strategy.entry('short',strategy.short,when=shortEntry)+if shortEntry+ strategy.entry('short',strategy.short)strategy.exit("x_short", "short",profit=tp, loss=sl)-strategy.close("short",when=ta.crossover(close,basis))+if ta.crossover(close,basis)+ strategy.close("short")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, 5 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.
⋯// © exlux99-//@version=5+//@version=6strategy("Bollinger Bands, RSI and ADX Trading System", overlay=true)⋯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 |
|---|---|---|---|
| Length (no label in the script) | 20 | int | vrsi |
| Over Sold (no label in the script) | 35 | int | co longEntry |
| Over Bought (no label in the script) | 65 | int | cu shortEntry |
| Length B (no label in the script) | 60 | int · min 1 | basis dev |
| Source | close | source | basis dev |
| StdDev | 2.0 | float · min 0.001 · max 50 | dev |
| ADX Smoothing | 14 | int | adx sig |
| DI Length | 14 | int | plus minus sig |
| Tp (no label in the script) | 90 | int · step 10 | exit X_long exit x_short |
| Sl (no label in the script) | 90 | int · step 10 | exit X_long exit x_short |
What it calculates
- RSI (
rsi,ta.rsiin v5)price, Length (20)vrsi · line 13 - Crossover (
crossover,ta.crossoverin v5)vrsi, Over Sold (35)co · line 14 - Crossunder (
crossunder,ta.crossunderin v5)vrsi, Over Bought (65)cu · line 15 - SMA (
sma,ta.smain v5)Source (close), Length B (60)basis · line 21 - Stdev (
stdev,ta.stdevin v5)Source (close), Length B (60)dev · line 22 - Change (
change,ta.changein v5)highup · line 29 - Change (
change,ta.changein v5)lowdown · line 30 - RMA (
rma,ta.rmain v5)tr, lentruerange · line 33 - RMA (
rma,ta.rmain v5)abs(plus - minus) / (sum == 0 ? 1 : sum), ADX Smoothing (14)adx · line 40
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 | longEntryclose < upper and crossover(vrsi,overSold) and sig < 32 | On | 46 |
| Exit X_long stop and limit | every bar | On | 47 |
| Close long | crossunder(close,basis) | On | 48 |
| Open short short | shortEntryclose > upper and crossunder(vrsi,overBought) and sig < 32 | On | 49 |
| Exit x_short stop and limit | every bar | On | 50 |
| Close short | crossover(close,basis) | On | 51 |
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 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −0.0% | +102.5% | 3 | 33% | 0.50 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +0.0% | +5.5% | 9 | 56% | 1.25 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 4 | 50% | 1.00 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.0% | +8.4% | 6 | 33% | 0.50 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.0% | +16.7% | 2 | 0% | 0.00 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 8 | 50% | 1.00 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 6 | 50% | 1.00 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −0.0% | +17.1% | 8 | 38% | 0.60 | 0.0% | 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 | 1 | 0% | −$0.90 |
| Sideways market | 2 | 50% | $0.00 |
| 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?
0.0%
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, 0.0% to 0.0%; the tick is what actually happened, 0.0%. Order luck alone moves it this much.
All 3 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 26 Jun 2024 61,806.00 | 26 Jun 2024 61,806.90 | 0 | $0.90 |
| long | 7 Aug 2024 56,022.00 | 7 Aug 2024 56,021.10 | 0 | −$0.90 |
| short | 19 Jul 2025 117,925.00 | 19 Jul 2025 117,926.00 | 0 | −$0.90 |
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 |
|---|---|---|---|---|---|
| Forex Scalping 1min Bollinger Bands, RSI and ADX Trading System this page | — | v4 strategy | −0.0% | 3 | 0.0% |
| 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% |
| Shorting when Bollinger Band Above Price with RSI (by Coinrule) by Coinrule | sma stdev rsi | v5 strategy | No trades on this market | ||
| Flawless Victory Strategy - 15min BTC Machine Learning Strategy by Bunghole | rma sma stdev | v4 strategy | +21.3% | 6 | 35.4% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 16 ms | With a workaround 1,000 bars in 47 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as 1, 0 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 46, 49) 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. 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/// © exlux99//@version=4strategy("Bollinger Bands, RSI and ADX Trading System", overlay=true)timeinrange(res, sess) => time(res, sess) != 0timer = color.red//bgcolor(timeinrange(timeframe.period, "0300-0600") or timeinrange(timeframe.period, "0900-1300") or timeinrange(timeframe.period, "2030-2300") ? timer : na, transp=70)//RSIlength = input( 20 )overSold = input( 35 )overBought = input( 65 )price = closevrsi = rsi(price, length)co = crossover(vrsi, overSold)cu = crossunder(vrsi, overBought)//if (not na(vrsi))//BBlengthB = input(60, minval=1)src = input(close, title="Source")mult = input(2.0, minval=0.001, maxval=50, title="StdDev")basis = sma(src, lengthB)dev = mult * stdev(src, lengthB)upper = basis + devlower = basis - dev//adxadxlen = input(14, title="ADX Smoothing")dilen = input(14, title="DI Length")dirmov(len) => up = change(high) down = -change(low) plusDM = na(up) ? na : (up > down and up > 0 ? up : 0) minusDM = na(down) ? na : (down > up and down > 0 ? down : 0) truerange = rma(tr, len) plus = fixnan(100 * rma(plusDM, len) / truerange) minus = fixnan(100 * rma(minusDM, len) / truerange) [plus, minus]adx(dilen, adxlen) => [plus, minus] = dirmov(dilen) sum = plus + minus adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)sig = adx(dilen, adxlen)longEntry = close < upper and crossover(vrsi,overSold) and sig < 32 //and (timeinrange(timeframe.period, "0301-0600") or timeinrange(timeframe.period, "0901-1300") or timeinrange(timeframe.period, "2031-2300"))shortEntry = close > upper and crossunder(vrsi,overBought) and sig < 32 //and (timeinrange(timeframe.period, "0301-0600") or timeinrange(timeframe.period, "0901-1300") or timeinrange(timeframe.period, "2031-2300"))tp=input(90, step=10)sl=input(90, step=10)strategy.entry("long",1,when=longEntry)strategy.exit("X_long", "long", profit=tp, loss=sl )strategy.close("long",when=crossunder(close,basis))strategy.entry('short',0,when=shortEntry)strategy.exit("x_short", "short",profit=tp, loss=sl)strategy.close("short",when=crossover(close,basis))