Pine Script v4 · Strategy
3x Supertrend and Stoch RSI
A Pine Script v4 strategy built on Supertrend (1, 10), RSI (close, 14) and SMA or Stoch (3). It has 4 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. 27 settings; defaults include Fast Supertrend ATR Length 10, Fast Supertrend ATR Multiplier 1 and Medium Supertrend ATR Length 11.
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 3x Supertrend and Stoch RSI repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 5 of 5 trades.
- How did 3x Supertrend and Stoch RSI do on BTCUSDT 1D with default settings?
- −128.66%
- From 26 Jan 2024 to 21 Oct 2026, over 24 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can 3x Supertrend and Stoch RSI 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.
- What alerts does 3x Supertrend and Stoch RSI have?
- 6
- alertLongCondition; alertShortCondition; alertLongProfit; alertLongLoss; and more.
- Does 3x Supertrend and Stoch RSI use a stop loss?
- Yes
- strategy.exit sets a stop on line 79, 91.
BTCUSDT · 1D · default settings
- Long Signal
- Short Signal
- Take profit
- Middle Line
- Stop Loss
- Fast Supertrend
- Medium Supertrend
- Slow Supertrend
- EMA
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −128.66%
- −$128,664.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 24
- 14 won · 10 lost
- Profitable
- 58.3%
- of closed trades
- Profit factor
- 0.85
- gross profit ÷ gross loss
- Max drawdown
- 207.63%
- −$264,988.00
One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A long 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
“Stop Loss Strategy”, “Take Profit Strategy” are declared but never read.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
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 supertrend → ta.supertrend, rsi → ta.rsi, sma → ta.sma, stoch → ta.stoch, ema → ta.ema, atr → ta.atr, crossover → ta.crossover, crossunder → ta.crossunder.
Same 24 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.float) → input.float()
- Line 8: input(type = input.integer) → input.int()
- Line 9: input(type = input.float) → input.float()
- Line 10: input(type = input.integer) → input.int()
36 more edits
- Line 11: input(type = input.float) → input.float()
- Line 12: input(type = input.integer) → input.int()
- Line 13: input(type = input.integer) → input.int()
- Line 14: input(type = input.integer) → input.int()
- Line 15: input(type = input.integer) → input.int()
- Line 16: input(type = input.source) → input.source()
- Line 17: input(type = input.bool) → input.bool()
- Line 18: input(type = input.integer) → input.int()
- Line 19: input(type = input.integer) → input.int()
- Line 20: input(type = input.integer) → input.int()
- Line 21: input(type = input.string) → input.string()
- Line 22: input(type = input.integer) → input.int()
- Line 23: input(type = input.float) → input.float()
- Line 24: input(type = input.string) → input.string()
- Line 25: input(type = input.integer) → input.int()
- Line 26: input(type = input.float) → input.float()
- Line 27: input(type = input.string) → input.string()
- Line 28: input(type = input.string) → input.string()
- Line 29: input(type = input.string) → input.string()
- Line 30: input(type = input.string) → input.string()
- Line 31: input(type = input.string) → input.string()
- Line 32: input(type = input.string) → input.string()
- Line 34: supertrend → ta.supertrend
- Line 35: supertrend → ta.supertrend
- Line 36: supertrend → ta.supertrend
- Line 41: rsi → ta.rsi
- Line 42: sma → ta.sma
- Line 42: stoch → ta.stoch
- Line 43: sma → ta.sma
- Line 45: ema → ta.ema
- Line 56: atr → ta.atr
- Line 57: atr → ta.atr
- Line 65: crossover → ta.crossover
- Line 66: crossunder → ta.crossunder
- Line 68: crossover → ta.crossover
- Line 69: crossunder → ta.crossunder
⋯// © M3RZI-//@version=4+//@version=5strategy("3x Supertrend and Stoch RSI", overlay = true, max_bars_back = 1000)//INPUTS-STATRLENGTH1 = input(10, title = "Fast Supertrend ATR Length", type = input.integer, group = "SUPERTREND SETTINGS")+STATRLENGTH1 = input.int(10, title = "Fast Supertrend ATR Length", group = "SUPERTREND SETTINGS")-STATRMULT1 = input(1, title = "Fast Supertrend ATR Multiplier", type = input.float, group = "SUPERTREND SETTINGS")+STATRMULT1 = input.float(1, title = "Fast Supertrend ATR Multiplier", group = "SUPERTREND SETTINGS")-STATRLENGTH2 = input(11, title = "Medium Supertrend ATR Length", type = input.integer, group = "SUPERTREND SETTINGS")+STATRLENGTH2 = input.int(11, title = "Medium Supertrend ATR Length", group = "SUPERTREND SETTINGS")-STATRMULT2 = input(2, title = "Medium Supertrend ATR Multiplier", type = input.float, group = "SUPERTREND SETTINGS")+STATRMULT2 = input.float(2, title = "Medium Supertrend ATR Multiplier", group = "SUPERTREND SETTINGS")-STATRLENGTH3 = input(12, title = "Slow Supertrend ATR Length", type = input.integer, group = "SUPERTREND SETTINGS")+STATRLENGTH3 = input.int(12, title = "Slow Supertrend ATR Length", group = "SUPERTREND SETTINGS")-STATRMULT3 = input(3, title = "Slow Supertrend ATR Multiplier", type = input.float, group = "SUPERTREND SETTINGS")+STATRMULT3 = input.float(3, title = "Slow Supertrend ATR Multiplier", group = "SUPERTREND SETTINGS")-stochK = input(3, title = "K (Stochastic Fast)", type = input.integer, group = "STOCHASTIC RSI SETTINGS")+stochK = input.int(3, title = "K (Stochastic Fast)", group = "STOCHASTIC RSI SETTINGS")-stochD = input(3, title = "D (Signal Line)", type = input.integer, group = "STOCHASTIC RSI SETTINGS")+stochD = input.int(3, title = "D (Signal Line)", group = "STOCHASTIC RSI SETTINGS")-rsiLength = input(14, title = "RSI Length", type = input.integer, group = "STOCHASTIC RSI SETTINGS")+rsiLength = input.int(14, title = "RSI Length", group = "STOCHASTIC RSI SETTINGS")-stochLength = input(14, title = "Stochastic Length", type = input.integer, group = "STOCHASTIC RSI SETTINGS")+stochLength = input.int(14, title = "Stochastic Length", group = "STOCHASTIC RSI SETTINGS")-rsiSource = input(close, title = "RSI Source", type = input.source, group = "STOCHASTIC RSI SETTINGS")+rsiSource = input.source(close, title = "RSI Source", group = "STOCHASTIC RSI SETTINGS")-stochRestrictions = input(false, title = "Restrict crosses to overbought/oversold territory", type = input.bool, group = "STOCHASTIC RSI SETTINGS")+stochRestrictions = input.bool(false, title = "Restrict crosses to overbought/oversold territory", group = "STOCHASTIC RSI SETTINGS")-overboughtLine = input(80, title = "Stochastic RSI Upper Band", type = input.integer, group = "STOCHASTIC RSI SETTINGS")+overboughtLine = input.int(80, title = "Stochastic RSI Upper Band", group = "STOCHASTIC RSI SETTINGS")-oversoldLine = input(20, title = "Stochastic RSI Lower Band", type = input.integer, group = "STOCHASTIC RSI SETTINGS")+oversoldLine = input.int(20, title = "Stochastic RSI Lower Band", group = "STOCHASTIC RSI SETTINGS")-EMALength = input(200, title = "EMA Length", type = input.integer, group = "EMA SETTINGS")+EMALength = input.int(200, title = "EMA Length", group = "EMA SETTINGS")-SLStrategy = input("ATR Based", title = "Stop Loss Strategy", options = ["ATR Based"],type = input.string, group = "POSITION EXIT SETTINGS")+SLStrategy = input.string("ATR Based", title = "Stop Loss Strategy", options = ["ATR Based"], group = "POSITION EXIT SETTINGS")-SLATRLength = input(14, title = "Stop Loss ATR Length", type = input.integer, group = "POSITION EXIT SETTINGS")+SLATRLength = input.int(14, title = "Stop Loss ATR Length", group = "POSITION EXIT SETTINGS")-SLATRMult = input(2.7, title = "Stop Loss ATR Multiplier", type = input.float, group = "POSITION EXIT SETTINGS")+SLATRMult = input.float(2.7, title = "Stop Loss ATR Multiplier", group = "POSITION EXIT SETTINGS")-TPStrategy = input("ATR Based", title = "Take Profit Strategy", options = ["ATR Based"],type = input.string, group = "POSITION EXIT SETTINGS")+TPStrategy = input.string("ATR Based", title = "Take Profit Strategy", options = ["ATR Based"], group = "POSITION EXIT SETTINGS")-TPATRLength = input(14, title = "Take Profit ATR Length", type = input.integer, group = "POSITION EXIT SETTINGS")+TPATRLength = input.int(14, title = "Take Profit ATR Length", group = "POSITION EXIT SETTINGS")-TPATRMult = input(1.6, title = "Take Profit ATR Multiplier", type = input.float, group = "POSITION EXIT SETTINGS")+TPATRMult = input.float(1.6, title = "Take Profit ATR Multiplier", group = "POSITION EXIT SETTINGS")-alertLongCondition = input("", title = "Long Signal", type = input.string, group = "ALERT SETTINGS") +alertLongCondition = input.string("", title = "Long Signal", group = "ALERT SETTINGS") -alertShortCondition = input("", title = "Short Signal", type = input.string, group = "ALERT SETTINGS")+alertShortCondition = input.string("", title = "Short Signal", group = "ALERT SETTINGS")-alertLongProfit = input("", title = "Long Take Profit", type = input.string, group = "ALERT SETTINGS") +alertLongProfit = input.string("", title = "Long Take Profit", group = "ALERT SETTINGS") -alertLongLoss = input("", title = "Long Stop Loss", type = input.string, group = "ALERT SETTINGS") +alertLongLoss = input.string("", title = "Long Stop Loss", group = "ALERT SETTINGS") -alertShortProfit = input("", title = "Short Take Profit", type = input.string, group = "ALERT SETTINGS") +alertShortProfit = input.string("", title = "Short Take Profit", group = "ALERT SETTINGS") -alertShortLoss = input("", title = "Short Stop loss", type = input.string, group = "ALERT SETTINGS") +alertShortLoss = input.string("", title = "Short Stop loss", group = "ALERT SETTINGS") //SUPERTRENDS-[superTrend1,dir1] = supertrend(STATRMULT1,STATRLENGTH1)+[superTrend1,dir1] = ta.supertrend(STATRMULT1,STATRLENGTH1)-[superTrend2,dir2] = supertrend(STATRMULT2,STATRLENGTH2)+[superTrend2,dir2] = ta.supertrend(STATRMULT2,STATRLENGTH2)-[superTrend3,dir3] = supertrend(STATRMULT3,STATRLENGTH3)+[superTrend3,dir3] = ta.supertrend(STATRMULT3,STATRLENGTH3)directionST1 = dir1 == 1 and dir1[1] == 1 ? false : dir1 == -1 and dir1[1] == -1 ? true : na⋯//STOCH RSI-rsi = rsi(rsiSource, rsiLength)+rsi = ta.rsi(rsiSource, rsiLength)-k = sma(stoch(rsi, rsi, rsi, stochLength), stochK)+k = ta.sma(ta.stoch(rsi, rsi, rsi, stochLength), stochK)-d = sma(k, stochD)+d = ta.sma(k, stochD)//EMA-ema = ema(close,EMALength)+ema = ta.ema(close,EMALength)//CONDITIONS LONG AND SHORT⋯var initial = 0-stopSize = atr(SLATRLength) * SLATRMult+stopSize = ta.atr(SLATRLength) * SLATRMult-profitSize = atr(TPATRLength) * TPATRMult+profitSize = ta.atr(TPATRLength) * TPATRMultlongStop = close - stopSize⋯if stochRestrictions- longCondition := close > ema and ((directionST1 == true and directionST2 == true) or (directionST2 == true and directionST3 == true)) and crossover(k,d) and k < oversoldLine and not long and not drawing+ longCondition := close > ema and ((directionST1 == true and directionST2 == true) or (directionST2 == true and directionST3 == true)) and ta.crossover(k,d) and k < oversoldLine and not long and not drawing- shortCondition := close < ema and ((directionST1 == false and directionST2 == false) or (directionST2 == false and directionST3 == false)) and crossunder(k,d) and k > overboughtLine and not short and not drawing+ shortCondition := close < ema and ((directionST1 == false and directionST2 == false) or (directionST2 == false and directionST3 == false)) and ta.crossunder(k,d) and k > overboughtLine and not short and not drawingelse- longCondition := close > ema and ((directionST1 == true and directionST2 == true) or (directionST2 == true and directionST3 == true)) and crossover(k,d) and not long and not drawing+ longCondition := close > ema and ((directionST1 == true and directionST2 == true) or (directionST2 == true and directionST3 == true)) and ta.crossover(k,d) and not long and not drawing- shortCondition := close < ema and ((directionST1 == false and directionST2 == false) or (directionST2 == false and directionST3 == false)) and crossunder(k,d) and not short and not drawing+ shortCondition := close < ema and ((directionST1 == false and directionST2 == false) or (directionST2 == false and directionST3 == false)) and ta.crossunder(k,d) and not short and not drawingif longCondition⋯Clean v5
VerifiedNothing to change.
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: 24 before, 0 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.
⋯// © M3RZI-//@version=5+//@version=6strategy("3x Supertrend and Stoch RSI", overlay = true, max_bars_back = 1000)⋯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 |
|---|---|---|---|
| SUPERTREND SETTINGS | |||
| Fast Supertrend ATR Length | 10 | int (written input.integer) | superTrend1 dir1 |
| Fast Supertrend ATR Multiplier | 1 | float | superTrend1 dir1 |
| Medium Supertrend ATR Length | 11 | int (written input.integer) | superTrend2 dir2 |
| Medium Supertrend ATR Multiplier | 2 | float | superTrend2 dir2 |
| Slow Supertrend ATR Length | 12 | int (written input.integer) | superTrend3 dir3 |
| Slow Supertrend ATR Multiplier | 3 | float | superTrend3 dir3 |
| STOCHASTIC RSI SETTINGS | |||
| K (Stochastic Fast) | 3 | int (written input.integer) | k |
| D (Signal Line) | 3 | int (written input.integer) | d |
| RSI Length | 14 | int (written input.integer) | rsi |
| Stochastic Length | 14 | int (written input.integer) | k |
| RSI Source | close | source | rsi |
| Restrict crosses to overbought/oversold territory | false | bool | line 64 |
| Stochastic RSI Upper Band | 80 | int (written input.integer) | shortCondition |
| Stochastic RSI Lower Band | 20 | int (written input.integer) | longCondition |
| EMA SETTINGS | |||
| EMA Length | 200 | int (written input.integer) | ema |
| POSITION EXIT SETTINGS | |||
| Stop Loss Strategy | ATR Based | string · options ["ATR Based"] | unused |
| Stop Loss ATR Length | 14 | int (written input.integer) | stopSize |
| Stop Loss ATR Multiplier | 2.7 | float | stopSize |
| Take Profit Strategy | ATR Based | string · options ["ATR Based"] | unused |
| Take Profit ATR Length | 14 | int (written input.integer) | profitSize |
| Take Profit ATR Multiplier | 1.6 | float | profitSize |
| ALERT SETTINGS | |||
| Long Signal | | string | alert |
| Short Signal | | string | alert |
| Long Take Profit | | string | alert |
| Long Stop Loss | | string | alert |
| Short Take Profit | | string | alert |
| Short Stop loss | | string | alert |
What it calculates
- Supertrend (
supertrend,ta.supertrendin v5)Fast Supertrend ATR Multiplier (1), Fast Supertrend ATR Length (10)superTrend1 · line 34 - Supertrend (
supertrend,ta.supertrendin v5)Fast Supertrend ATR Multiplier (1), Fast Supertrend ATR Length (10)dir1 · line 34 - Supertrend (
supertrend,ta.supertrendin v5)Medium Supertrend ATR Multiplier (2), Medium Supertrend ATR Length (11)superTrend2 · line 35 - Supertrend (
supertrend,ta.supertrendin v5)Medium Supertrend ATR Multiplier (2), Medium Supertrend ATR Length (11)dir2 · line 35 - Supertrend (
supertrend,ta.supertrendin v5)Slow Supertrend ATR Multiplier (3), Slow Supertrend ATR Length (12)superTrend3 · line 36 - Supertrend (
supertrend,ta.supertrendin v5)Slow Supertrend ATR Multiplier (3), Slow Supertrend ATR Length (12)dir3 · line 36 - RSI (
rsi,ta.rsiin v5)RSI Source (close), RSI Length (14)rsi · line 41 - SMA / Stoch (
sma,ta.smain v5)stoch(rsi, rsi, rsi, stochLength), K (Stochastic Fast) (3)k · line 42 - SMA (
sma,ta.smain v5)k, D (Signal Line) (3)d · line 43 - EMA (
ema,ta.emain v5)close, EMA Length (200)ema · line 45 - ATR (
atr,ta.atrin v5)Stop Loss ATR Length (14)stopSize · line 56 - ATR (
atr,ta.atrin v5)Take Profit ATR Length (14)profitSize · line 57
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.
The script has 71 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Long long | longCondition | On | 78 |
| Exit Long exit stop and limit | longCondition | On | 79 |
| Open Short short | shortCondition | On | 90 |
| Exit Short exit stop and limit | shortCondition | On | 91 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Alerts
| Alert | Call | Message | Line |
|---|---|---|---|
| (no title) | alert | alertLongCondition | 80 |
| (no title) | alert | alertShortCondition | 92 |
| (no title) | alert | alertLongProfit | 99 |
| (no title) | alert | alertLongLoss | 102 |
| (no title) | alert | alertShortProfit | 108 |
| (no title) | alert | alertShortLoss | 111 |
Does it repaint?
No
No repainting patterns in the source, and the live replay matched history.
- 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 | −128.7% | +102.5% | 24 | 58% | 0.85 | 207.6% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −113.6% | +5.5% | 24 | 42% | 0.54 | 111.2% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +5.4% | +9.8% | 27 | 63% | 1.14 | 11.3% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +1.7% | +8.4% | 21 | 67% | 1.27 | 2.7% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.4% | +16.7% | 21 | 57% | 0.87 | 1.5% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.1% | +21.5% | 25 | 68% | 1.23 | 0.2% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −6.0% | +148.3% | 26 | 50% | 0.50 | 7.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +1.4% | +17.1% | 23 | 78% | 2.63 | 0.4% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
Settings heatmap
Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (K (Stochastic Fast) 4, D (Signal Line) 2) made +238.8% before 26 Dec 2025 and −129.4% after it, against −189.5% for the defaults. 31% of the 16 combinations made money in-sample and 25% out-of-sample.
| D (Signal Line) ↓ · K (Stochastic Fast) → | 2 | 3 | 4 | 5 |
|---|---|---|---|---|
| 2 | −333% | −15% | +239% | +103% |
| 3 | −227% | +61% | −27% | −183% |
| 4 | −104% | −131% | −11% | −223% |
| 5 | +39% | −115% | −134% | +155% |
| D (Signal Line) ↓ · K (Stochastic Fast) → | 2 | 3 | 4 | 5 |
|---|---|---|---|---|
| 2 | −21% | −156% | −129% | −10% |
| 3 | −68% | −190% | −17% | +14% |
| 4 | −46% | −153% | −14% | +55% |
| 5 | −90% | −98% | +7% | +21% |
Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. 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 | 10 | 50% | −$141,358.00 |
| Sideways market | 8 | 75% | $147,847.00 |
| Falling market | 6 | 50% | −$135,153.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
6,901.9%
The 95th percentile of the worst drawdown when the same 24 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 122.8% to 6,901.9%; the tick is what actually happened, 182.6%. Order luck alone moves it this much.
All 24 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 6 Sep 2024 56,180.00 | 19 Sep 2024 63,049.20 | 13 | −$68,691.90 |
| long | 28 Sep 2024 65,769.90 | 3 Oct 2024 59,855.50 | 5 | −$59,144.80 |
| long | 21 Oct 2024 69,032.00 | 29 Oct 2024 72,108.60 | 8 | $30,766.30 |
| long | 22 Nov 2024 98,317.10 | 5 Dec 2024 104,014.00 | 13 | $56,965.00 |
| long | 13 Dec 2024 100,004.00 | 16 Dec 2024 106,777.00 | 3 | $67,728.20 |
| long | 23 Jan 2025 103,707.00 | 3 Feb 2025 91,583.90 | 11 | −$121,228.00 |
| short | 23 Mar 2025 83,840.60 | 6 Apr 2025 77,651.90 | 14 | $61,886.60 |
| short | 16 Apr 2025 83,644.00 | 23 Apr 2025 94,155.50 | 7 | −$105,115.00 |
| long | 2 May 2025 96,489.90 | 8 May 2025 101,153.00 | 6 | $46,630.20 |
| long | 19 May 2025 106,454.00 | 21 May 2025 110,790.00 | 2 | $43,357.40 |
| long | 28 May 2025 108,938.00 | 5 Jun 2025 100,821.00 | 8 | −$81,168.10 |
| long | 17 Jun 2025 106,795.00 | 22 Jun 2025 99,054.20 | 5 | −$77,403.40 |
| long | 4 Jul 2025 109,585.00 | 10 Jul 2025 113,886.00 | 6 | $43,008.20 |
| long | 28 Jul 2025 119,416.00 | 14 Aug 2025 123,875.00 | 17 | $44,594.10 |
| long | 18 Sep 2025 116,448.00 | 25 Sep 2025 109,876.00 | 7 | −$65,716.90 |
| short | 4 Nov 2025 106,583.00 | 4 Nov 2025 100,755.00 | 0 | $58,278.80 |
| short | 14 Nov 2025 99,692.00 | 16 Nov 2025 93,061.00 | 2 | $66,310.70 |
| short | 1 Dec 2025 90,360.00 | 1 Dec 2025 84,632.70 | 0 | $57,273.00 |
| short | 6 Dec 2025 89,330.00 | 30 Jan 2026 83,075.70 | 55 | $62,543.70 |
| short | 6 Feb 2026 62,909.90 | 17 Apr 2026 77,657.20 | 70 | −$147,474.00 |
| long | 11 May 2026 82,210.10 | 18 May 2026 76,716.10 | 7 | −$54,940.20 |
| short | 28 May 2026 74,449.30 | 1 Jun 2026 71,270.40 | 4 | $31,789.50 |
| long | 5 Sep 2026 79,660.80 | 21 Sep 2026 83,697.60 | 16 | $40,368.00 |
| long | 5 Oct 2026 86,530.00 | 8 Oct 2026 80,601.80 | 3 | −$59,281.80 |
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 |
|---|---|---|---|---|---|
| 3x Supertrend and Stoch RSI this page | — | v4 strategy | −128.7% | 24 | 207.6% |
| 3 x EMA + Stochastic RSI + ATR by tomimarson | ema rsi sma atr | v4 strategy | −42.3% | 18 | 44.8% |
| Atrend by OTS by prim722 | ema rsi sma atr | v4 strategy | +12.1% | 76 | 34.4% |
| EMA crossover (daily TF) by tradeswithashish | ema sma rsi atr | v5 strategy | +11.0% | 12 | 11.6% |
| Stochastic Moving Average by LucasVivien | stoch sma ema atr | v5 strategy | +2.8% | 7 | 4.4% |
| Delta-RSI Strategy (with filters) by tbiktag | rsi ema atr sma | v4 strategy | −28.8% | 71 | 83.8% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 50 ms | Yes 1,000 bars in 132 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
“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/// © M3RZI//@version=4strategy("3x Supertrend and Stoch RSI", overlay = true, max_bars_back = 1000)//INPUTSSTATRLENGTH1 = input(10, title = "Fast Supertrend ATR Length", type = input.integer, group = "SUPERTREND SETTINGS")STATRMULT1 = input(1, title = "Fast Supertrend ATR Multiplier", type = input.float, group = "SUPERTREND SETTINGS")STATRLENGTH2 = input(11, title = "Medium Supertrend ATR Length", type = input.integer, group = "SUPERTREND SETTINGS")STATRMULT2 = input(2, title = "Medium Supertrend ATR Multiplier", type = input.float, group = "SUPERTREND SETTINGS")STATRLENGTH3 = input(12, title = "Slow Supertrend ATR Length", type = input.integer, group = "SUPERTREND SETTINGS")STATRMULT3 = input(3, title = "Slow Supertrend ATR Multiplier", type = input.float, group = "SUPERTREND SETTINGS")stochK = input(3, title = "K (Stochastic Fast)", type = input.integer, group = "STOCHASTIC RSI SETTINGS")stochD = input(3, title = "D (Signal Line)", type = input.integer, group = "STOCHASTIC RSI SETTINGS")rsiLength = input(14, title = "RSI Length", type = input.integer, group = "STOCHASTIC RSI SETTINGS")stochLength = input(14, title = "Stochastic Length", type = input.integer, group = "STOCHASTIC RSI SETTINGS")rsiSource = input(close, title = "RSI Source", type = input.source, group = "STOCHASTIC RSI SETTINGS")stochRestrictions = input(false, title = "Restrict crosses to overbought/oversold territory", type = input.bool, group = "STOCHASTIC RSI SETTINGS")overboughtLine = input(80, title = "Stochastic RSI Upper Band", type = input.integer, group = "STOCHASTIC RSI SETTINGS")oversoldLine = input(20, title = "Stochastic RSI Lower Band", type = input.integer, group = "STOCHASTIC RSI SETTINGS")EMALength = input(200, title = "EMA Length", type = input.integer, group = "EMA SETTINGS")SLStrategy = input("ATR Based", title = "Stop Loss Strategy", options = ["ATR Based"],type = input.string, group = "POSITION EXIT SETTINGS")SLATRLength = input(14, title = "Stop Loss ATR Length", type = input.integer, group = "POSITION EXIT SETTINGS")SLATRMult = input(2.7, title = "Stop Loss ATR Multiplier", type = input.float, group = "POSITION EXIT SETTINGS")TPStrategy = input("ATR Based", title = "Take Profit Strategy", options = ["ATR Based"],type = input.string, group = "POSITION EXIT SETTINGS")TPATRLength = input(14, title = "Take Profit ATR Length", type = input.integer, group = "POSITION EXIT SETTINGS")TPATRMult = input(1.6, title = "Take Profit ATR Multiplier", type = input.float, group = "POSITION EXIT SETTINGS")alertLongCondition = input("", title = "Long Signal", type = input.string, group = "ALERT SETTINGS") alertShortCondition = input("", title = "Short Signal", type = input.string, group = "ALERT SETTINGS")alertLongProfit = input("", title = "Long Take Profit", type = input.string, group = "ALERT SETTINGS") alertLongLoss = input("", title = "Long Stop Loss", type = input.string, group = "ALERT SETTINGS") alertShortProfit = input("", title = "Short Take Profit", type = input.string, group = "ALERT SETTINGS") alertShortLoss = input("", title = "Short Stop loss", type = input.string, group = "ALERT SETTINGS") //SUPERTRENDS[superTrend1,dir1] = supertrend(STATRMULT1,STATRLENGTH1)[superTrend2,dir2] = supertrend(STATRMULT2,STATRLENGTH2)[superTrend3,dir3] = supertrend(STATRMULT3,STATRLENGTH3)directionST1 = dir1 == 1 and dir1[1] == 1 ? false : dir1 == -1 and dir1[1] == -1 ? true : nadirectionST2 = dir2 == 1 and dir2[1] == 1 ? false : dir2 == -1 and dir2[1] == -1 ? true : nadirectionST3 = dir3 == 1 and dir3[1] == 1 ? false : dir3 == -1 and dir3[1] == -1 ? true : na//STOCH RSIrsi = rsi(rsiSource, rsiLength)k = sma(stoch(rsi, rsi, rsi, stochLength), stochK)d = sma(k, stochD)//EMAema = ema(close,EMALength)//CONDITIONS LONG AND SHORTvar long = falsevar longCondition = falsevar short = falsevar shortCondition = falsevar drawing = falsevar TP = 0.0var SL = 0.0var middle = 0.0var initial = 0stopSize = atr(SLATRLength) * SLATRMultprofitSize = atr(TPATRLength) * TPATRMultlongStop = close - stopSizelongProfit = close + profitSizecurrent = closeshortStop = close + stopSizeshortProfit = close - profitSizebarInitial = bar_indexif stochRestrictions longCondition := close > ema and ((directionST1 == true and directionST2 == true) or (directionST2 == true and directionST3 == true)) and crossover(k,d) and k < oversoldLine and not long and not drawing shortCondition := close < ema and ((directionST1 == false and directionST2 == false) or (directionST2 == false and directionST3 == false)) and crossunder(k,d) and k > overboughtLine and not short and not drawingelse longCondition := close > ema and ((directionST1 == true and directionST2 == true) or (directionST2 == true and directionST3 == true)) and crossover(k,d) and not long and not drawing shortCondition := close < ema and ((directionST1 == false and directionST2 == false) or (directionST2 == false and directionST3 == false)) and crossunder(k,d) and not short and not drawingif longCondition long := true short := false drawing := true TP := longProfit middle := current SL := longStop initial := barInitial strategy.entry("Long", strategy.long, 10) strategy.exit("Long exit","Long", limit = TP, stop = SL) alert(alertLongCondition,alert.freq_once_per_bar_close) //label.new(bar_index,low,text = "Long\nTP:"+tostring(TP)+"\nSL:"+tostring(SL)+"\nAbierto:"+tostring(current), yloc = yloc.belowbar, textcolor = color.white, color = color.green, size = size.small, style = label.style_label_up)if shortCondition short := true long := false drawing := true TP := shortProfit middle := current SL := shortStop initial := barInitial strategy.entry("Short", strategy.short, 10) strategy.exit("Short exit","Short",limit = TP , stop = SL) alert(alertShortCondition,alert.freq_once_per_bar_close) //label.new(bar_index,high,text = "Short\nTP:"+tostring(TP)+"\nSL:"+tostring(SL)+"\nAbierto:"+tostring(current), yloc = yloc.abovebar, textcolor = color.white, color = color.red, size = size.small, style = label.style_label_down)if long and (high[1] >= TP or low[1] <= SL) drawing := false long := false if high[1] >= TP label.new(bar_index[int((bar_index - initial)/2)],TP, text = "Win (Long)", textcolor = color.white, color = color.green, size = size.small, style = label.style_label_down) alert(alertLongProfit,alert.freq_once_per_bar_close) else label.new(bar_index[int((bar_index - initial)/2)],SL, text = "Lose (Long)", textcolor = color.white, color = color.red, size = size.small, style = label.style_label_up) alert(alertLongLoss,alert.freq_once_per_bar_close)if short and (low[1] <= TP or high[1] >= SL) drawing := false short := false if low[1] <= TP label.new(bar_index[int((bar_index - initial)/2)],TP, text = "Win (short)", textcolor = color.white, color = color.green, size = size.small, style = label.style_label_up) alert(alertShortProfit,alert.freq_once_per_bar_close) else label.new(bar_index[int((bar_index - initial)/2)],SL, text = "Lose (short)", textcolor = color.white, color = color.red, size = size.small, style = label.style_label_down) alert(alertShortLoss,alert.freq_once_per_bar_close)//DRAWINGplotshape(longCondition, title = "Long Signal", location=location.belowbar, style=shape.labelup, color=color.green, textcolor=color.white, size=size.small, text="Long")plotshape(shortCondition, title = "Short Signal", location=location.abovebar, style=shape.labeldown, color=color.red, textcolor=color.white, size=size.small, text="Short")profitLine = plot(drawing and drawing[1] ? TP : na, title = "Take profit", color = color.green, style = plot.style_linebr)currentLine =plot(drawing and drawing[1] ? middle : na, title = "Middle Line", color = color.white, style = plot.style_linebr)lossLine = plot(drawing and drawing[1] ? SL : na, title = "Stop Loss", color = color.red, style = plot.style_linebr)fill(currentLine,profitLine, title = "Profit Background" ,color = color.new(color.green,75))fill(currentLine,lossLine, title = "Loss Background" ,color = color.new(color.red,75))plot(superTrend1, title = "Fast Supertrend", color = dir1 == 1 and dir1[1] == 1 ? color.red : dir1 == -1 and dir1[1] == -1 ? color.green : na)plot(superTrend2, title = "Medium Supertrend", color = dir2 == 1 and dir2[1] == 1 ? color.red : dir2 == -1 and dir2[1] == -1 ? color.green : na)plot(superTrend3, title = "Slow Supertrend", color = dir3 == 1 and dir3[1] == 1 ? color.red : dir3 == -1 and dir3[1] == -1 ? color.green : na)plot(ema, title = "EMA",color = color.yellow)//plot(k, color = color.blue)//plot(d, color = color.orange)//h1 = hline(80)//h2 = hline(20)//fill(h1,h2, color = color.new(color.purple,60))