Pine Script v5 · Strategy
Triple Supertrend with EMA and ADX strategy
A Pine Script v5 strategy built on Supertrend (1, 10), EMA (close, 200) and DMI (14, 14). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 12 settings; defaults include ATR Multi 1, ATR Multi 2 and ATR Multi 3.
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 Triple Supertrend with EMA and ADX strategy repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 13 of 13 trades.
- How did Triple Supertrend with EMA and ADX strategy do on BTCUSDT 1D with default settings?
- −0.95%
- From 26 Jan 2024 to 21 Oct 2026, over 58 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does Triple Supertrend with EMA and ADX strategy 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: 58 before, 299 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 Triple Supertrend with EMA and ADX strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Triple Supertrend with EMA and ADX strategy run in Zeal Terminal?
- Yes
- It compiles in 41 ms and runs 1,000 bars in 85 ms, in the browser.
BTCUSDT · 1D · default settings
- R1
- S1
- R1
- S1
- R1
- S1
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −0.95%
- −$9,519.03
- Buy and hold
- +102.5%
- same period
- Closed trades
- 58
- 23 won · 35 lost
- Profitable
- 39.7%
- of closed trades
- Profit factor
- 0.93
- gross profit ÷ gross loss
- Max drawdown
- 5.29%
- −$53,250.50
One run with the author's default settings, $1,000,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 stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
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.
-
Note
Uses an argument v6 removed
when = on line 59, 60. 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 |
|---|---|---|---|
| ST 1 | |||
| ATR Multi | 1 | float · min 1 · max 6 · step 0.5 | superTrend1 dir1 |
| ATR Multi | 10 | int · min 5 · max 25 · step 1 | superTrend1 dir1 |
| ST 2 | |||
| ATR Multi | 2 | float · min 1 · max 6 · step 0.5 | superTrend2 dir2 |
| ATR Multi | 15 | int · min 5 · max 25 · step 1 | superTrend2 dir2 |
| ST 3 | |||
| ATR Multi | 3 | float · min 1 · max 6 · step 0.5 | superTrend3 dir3 |
| ATR Multi | 20 | int · min 5 · max 25 · step 1 | superTrend3 dir3 |
| EMA Len | 200 | int · min 5 · max 250 · step 1 | EMA |
| ADX Len | 14 | int · min 1 · max 25 · step 1 | diplus diminus adx |
| Di Len | 14 | int · min 1 · max 25 · step 1 | diplus diminus adx |
| adx filter | 25 | float · min 1 · max 50 · step 0.5 | adxup adxdown |
| Add Adx & EMA filter | false | bool | dir_long dir_short |
| Allow Reentry | true | bool | longenter shortenter |
What it calculates
- SupertrendATR Multi (1), ATR Multi (10)
superTrend1 · line 22 - SupertrendATR Multi (1), ATR Multi (10)
dir1 · line 22 - SupertrendATR Multi (2), ATR Multi (15)
superTrend2 · line 23 - SupertrendATR Multi (2), ATR Multi (15)
dir2 · line 23 - SupertrendATR Multi (3), ATR Multi (20)
superTrend3 · line 24 - SupertrendATR Multi (3), ATR Multi (20)
dir3 · line 24 - EMAclose, EMA Len (200)
EMA · line 25 - DMIDi Len (14), ADX Len (14)
diplus · line 26 - DMIDi Len (14), ADX Len (14)
diminus · line 26 - DMIDi Len (14), ADX Len (14)
adx · line 26 - Barssincedir_long
buy1 · line 63 - Barssincedir_short
sell1 · line 64
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 BUY long | longenterif(renetry == false)
dir_long and long_position == false
else
dir_long
| On | 59 |
| Open SELL short | shortenterif(renetry == false)
dir_short and long_position == true
else
dir_short
| On | 60 |
| Close BUY | every bar | On | 61 |
| Close SELL | every bar | On | 62 |
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, 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 | −1.0% | +102.5% | 58 | 40% | 0.93 | 5.3% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −1.2% | +5.5% | 61 | 28% | 0.75 | 2.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +0.0% | +9.8% | 52 | 40% | 1.04 | 0.2% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.0% | +8.4% | 52 | 29% | 1.18 | 0.1% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.0% | +16.7% | 53 | 42% | 1.06 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 53 | 36% | 1.15 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −0.0% | +148.3% | 49 | 41% | 0.94 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.0% | +17.1% | 51 | 39% | 1.31 | 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 | 18 | 39% | −$12,554.20 |
| Sideways market | 27 | 44% | −$8,811.20 |
| Falling market | 13 | 31% | $11,846.40 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
6.9%
The 95th percentile of the worst drawdown when the same 58 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 3.1% to 6.9%; the tick is what actually happened, 5.1%. Order luck alone moves it this much.
All 58 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 27 Jan 2024 41,823.50 | 8 Feb 2024 44,349.60 | 12 | −$2,526.09 |
| long | 28 Feb 2024 57,037.30 | 17 Mar 2024 65,300.60 | 18 | $8,263.29 |
| short | 20 Mar 2024 61,937.40 | 26 Mar 2024 69,880.00 | 6 | −$7,942.59 |
| short | 3 Apr 2024 65,464.00 | 8 Apr 2024 69,360.40 | 5 | −$3,896.39 |
| short | 13 Apr 2024 67,116.50 | 23 Apr 2024 66,819.30 | 10 | $297.20 |
| short | 29 Apr 2024 63,118.60 | 4 May 2024 62,882.00 | 5 | $236.61 |
| short | 11 May 2024 60,800.00 | 16 May 2024 66,206.50 | 5 | −$5,406.52 |
| long | 21 May 2024 71,446.60 | 30 May 2024 67,652.40 | 9 | −$3,794.21 |
| long | 5 Jun 2024 70,537.80 | 12 Jun 2024 67,314.20 | 7 | −$3,223.60 |
| short | 24 Jun 2024 63,210.00 | 1 Jul 2024 62,772.00 | 7 | $438.00 |
| short | 4 Jul 2024 60,208.60 | 7 Jul 2024 58,230.10 | 3 | $1,978.44 |
| short | 8 Jul 2024 55,857.80 | 14 Jul 2024 59,204.00 | 6 | −$3,346.20 |
| long | 16 Jul 2024 64,724.10 | 1 Aug 2024 64,628.00 | 16 | −$96.05 |
| short | 4 Aug 2024 60,698.00 | 9 Aug 2024 61,686.00 | 5 | −$988.01 |
| long | 24 Aug 2024 64,037.20 | 28 Aug 2024 59,415.00 | 4 | −$4,622.24 |
| short | 7 Sep 2024 53,963.00 | 10 Sep 2024 57,042.00 | 3 | −$3,079.04 |
| long | 20 Sep 2024 62,948.00 | 1 Oct 2024 63,327.60 | 11 | $379.60 |
| long | 15 Oct 2024 66,084.00 | 24 Oct 2024 66,668.60 | 9 | $584.65 |
| long | 29 Oct 2024 69,962.20 | 2 Nov 2024 69,496.00 | 4 | −$466.21 |
| long | 7 Nov 2024 75,572.00 | 26 Nov 2024 93,010.00 | 19 | $17,438.00 |
| long | 30 Nov 2024 97,460.00 | 19 Dec 2024 100,204.00 | 19 | $2,744.01 |
| short | 23 Dec 2024 95,186.30 | 26 Dec 2024 99,429.60 | 3 | −$4,243.33 |
| short | 28 Dec 2024 94,299.00 | 4 Jan 2025 98,174.20 | 7 | −$3,875.14 |
| short | 10 Jan 2025 92,552.50 | 15 Jan 2025 96,560.90 | 5 | −$4,008.36 |
| long | 18 Jan 2025 104,077.00 | 2 Feb 2025 100,636.00 | 15 | −$3,441.81 |
| short | 25 Feb 2025 91,552.90 | 2 Mar 2025 86,064.50 | 5 | $5,488.34 |
| long | 3 Mar 2025 94,270.00 | 10 Mar 2025 80,734.50 | 7 | −$13,535.50 |
| short | 11 Mar 2025 78,595.90 | 20 Mar 2025 86,845.90 | 9 | −$8,250.07 |
| short | 30 Mar 2025 82,648.50 | 10 Apr 2025 82,615.20 | 11 | $33.31 |
| long | 23 Apr 2025 93,443.00 | 5 May 2025 94,277.60 | 12 | $834.62 |
| long | 7 May 2025 96,834.00 | 24 May 2025 107,318.00 | 17 | $10,484.30 |
| long | 10 Jun 2025 110,263.00 | 13 Jun 2025 105,672.00 | 3 | −$4,591.28 |
| short | 23 Jun 2025 100,964.00 | 24 Jun 2025 105,334.00 | 1 | −$4,370.07 |
| long | 10 Jul 2025 111,234.00 | 16 Jul 2025 117,758.00 | 6 | $6,524.08 |
| short | 3 Aug 2025 112,546.00 | 8 Aug 2025 117,472.00 | 5 | −$4,925.67 |
| long | 14 Aug 2025 123,306.00 | 15 Aug 2025 118,295.00 | 1 | −$5,011.35 |
| short | 20 Aug 2025 112,873.00 | 23 Aug 2025 116,936.00 | 3 | −$4,063.05 |
| short | 26 Aug 2025 110,112.00 | 4 Sep 2025 111,706.00 | 9 | −$1,593.74 |
| short | 24 Sep 2025 111,999.00 | 29 Sep 2025 112,164.00 | 5 | −$165.16 |
| long | 2 Oct 2025 118,595.00 | 8 Oct 2025 121,333.00 | 6 | $2,737.97 |
| short | 11 Oct 2025 112,774.00 | 26 Oct 2025 111,646.00 | 15 | $1,128.22 |
| short | 30 Oct 2025 110,021.00 | 11 Nov 2025 106,011.00 | 12 | $4,010.17 |
| short | 14 Nov 2025 99,692.00 | 27 Nov 2025 90,484.00 | 13 | $9,208.02 |
| short | 2 Dec 2025 86,286.00 | 3 Dec 2025 91,277.90 | 1 | −$4,991.87 |
| short | 19 Dec 2025 85,516.40 | 4 Jan 2026 90,628.00 | 16 | −$5,111.60 |
| long | 15 Jan 2026 96,951.80 | 20 Jan 2026 92,631.00 | 5 | −$4,320.79 |
| short | 26 Jan 2026 86,670.40 | 26 Feb 2026 67,988.00 | 31 | $18,682.30 |
| long | 17 Mar 2026 74,884.70 | 19 Mar 2026 71,246.60 | 2 | −$3,638.12 |
| long | 8 Apr 2026 71,924.20 | 13 Apr 2026 70,741.60 | 5 | −$1,182.66 |
| long | 14 Apr 2026 74,418.00 | 20 Apr 2026 73,801.80 | 6 | −$616.20 |
| long | 23 Apr 2026 78,178.20 | 30 Apr 2026 75,780.00 | 7 | −$2,398.22 |
| long | 2 May 2026 78,231.10 | 14 May 2026 79,313.60 | 12 | $1,082.48 |
| short | 28 May 2026 74,449.30 | 8 Jun 2026 63,332.00 | 11 | $11,117.30 |
| short | 25 Jun 2026 61,078.00 | 3 Jul 2026 61,560.00 | 8 | −$482.00 |
| long | 22 Jul 2026 66,556.10 | 25 Jul 2026 64,140.00 | 3 | −$2,416.15 |
| long | 6 Aug 2026 64,665.20 | 12 Aug 2026 63,600.00 | 6 | −$1,065.23 |
| long | 18 Aug 2026 64,532.10 | 11 Sep 2026 76,568.70 | 24 | $12,036.60 |
| long | 19 Sep 2026 80,883.90 | 8 Oct 2026 83,321.80 | 19 | $2,437.95 |
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 |
|---|---|---|---|---|---|
| Triple Supertrend with EMA and ADX strategy this page | — | v5 strategy | −1.0% | 58 | 5.3% |
| 5-10-20 Cross by aadilpatel07 | supertrend ema | v4 strategy | +36.0% | 35 | 51.2% |
| [Strategy] - EMA 10,20 59 with Profit Displayed by mattehalen | ema barssince | v4 strategy | −2,311,450.0% | 793 | 8,424,000.0% |
| scalping with market facilitation by trent777brown | ema dmi barssince | v5 strategy | No trades on this market | ||
| Mathias & Christer EMA by mattehalen | ema barssince | v4 strategy | No trades on this market | ||
| JS-TechTrading- Supertrend-Strategy_Basic version by JS_TechTrading | supertrend ema | v5 strategy | +0.1% | 2 | 0.0% |
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.
- 2 strategy calls use the when = argument (line 59, 60). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- No v6-only features. v6 is not needed to run this script.
Same 58 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 59: when = longenter → if block
- Line 60: when = shortenter → if block
⋯ long_position := false-strategy.entry('BUY', strategy.long, when=longenter)+if longenter+ strategy.entry('BUY', strategy.long)-strategy.entry('SELL', strategy.short, when=shortenter) +if shortenter+ strategy.entry('SELL', strategy.short) strategy.close('BUY', Exit_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: 58 before, 299 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.
⋯// ©kunjandetroja-//@version=5+//@version=6strategy('Triple Supertrend with EMA and ADX', overlay=true)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 41 ms | Yes 1,000 bars in 85 ms | Not measured |
| PineTS | Not tested | Not tested | 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.
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/// ©kunjandetroja//@version=5strategy('Triple Supertrend with EMA and ADX', overlay=true)m1 = input.float(1,"ATR Multi",minval = 1,maxval= 6,step=0.5,group='ST 1')m2 = input.float(2,"ATR Multi",minval = 1,maxval= 6,step=0.5,group='ST 2')m3 = input.float(3,"ATR Multi",minval = 1,maxval= 6,step=0.5,group='ST 3')p1 = input.int(10,"ATR Multi",minval = 5,maxval= 25,step=1,group='ST 1')p2 = input.int(15,"ATR Multi",minval = 5,maxval= 25,step=1,group='ST 2')p3 = input.int(20,"ATR Multi",minval = 5,maxval= 25,step=1,group='ST 3')len_EMA = input.int(200,"EMA Len",minval = 5,maxval= 250,step=1)len_ADX = input.int(14,"ADX Len",minval = 1,maxval= 25,step=1)len_Di = input.int(14,"Di Len",minval = 1,maxval= 25,step=1)adx_above = input.float(25,"adx filter",minval = 1,maxval= 50,step=0.5)var bool long_position = falseadx_filter = input.bool(false, "Add Adx & EMA filter")renetry = input.bool(true, "Allow Reentry")f_getColor_Resistance(_dir, _color) => _dir == 1 and _dir == _dir[1] ? _color : naf_getColor_Support(_dir, _color) => _dir == -1 and _dir == _dir[1] ? _color : na[superTrend1, dir1] = ta.supertrend(m1, p1)[superTrend2, dir2] = ta.supertrend(m2, p2)[superTrend3, dir3] = ta.supertrend(m3, p3)EMA = ta.ema(close, len_EMA)[diplus,diminus,adx] = ta.dmi(len_Di,len_ADX)// ADX Filteradxup = adx > adx_above and close > EMAadxdown = adx > adx_above and close < EMAsum_dir = dir1 + dir2 + dir3dir_long = if(adx_filter == false) sum_dir == -3else sum_dir == -3 and adxupdir_short = if(adx_filter == false) sum_dir == 3else sum_dir == 3 and adxdownExit_long = dir1 == 1 and dir1 != dir1[1]Exit_short = dir1 == -1 and dir1 != dir1[1]// BuySignal = dir_long and dir_long != dir_long[1]// SellSignal = dir_short and dir_short != dir_short[1]// if BuySignal// label.new(bar_index, low, 'Long', style=label.style_label_up)// if SellSignal// label.new(bar_index, high, 'Short', style=label.style_label_down)longenter = if(renetry == false) dir_long and long_position == falseelse dir_longshortenter = if(renetry == false) dir_short and long_position == trueelse dir_shortif longenter long_position := trueif shortenter long_position := falsestrategy.entry('BUY', strategy.long, when=longenter)strategy.entry('SELL', strategy.short, when=shortenter) strategy.close('BUY', Exit_long)strategy.close('SELL', Exit_short)buy1 = ta.barssince(dir_long)sell1 = ta.barssince(dir_short)colR1 = f_getColor_Resistance(dir1, color.red)colS1 = f_getColor_Support(dir1, color.green)colR2 = f_getColor_Resistance(dir2, color.orange)colS2 = f_getColor_Support(dir2, color.yellow)colR3 = f_getColor_Resistance(dir3, color.blue)colS3 = f_getColor_Support(dir3, color.maroon)plot(superTrend1, 'R1', colR1, linewidth=2)plot(superTrend1, 'S1', colS1, linewidth=2)plot(superTrend2, 'R1', colR2, linewidth=2)plot(superTrend2, 'S1', colS2, linewidth=2)plot(superTrend3, 'R1', colR3, linewidth=2)plot(superTrend3, 'S1', colS3, linewidth=2)// // Intraday only// var int new_day = na// var int new_month = na// var int new_year = na// var int close_trades_after_time_of_day = na// if dayofmonth != dayofmonth[1]// new_day := dayofmonth// if month != month[1]// new_month := month// if year != year[1]// new_year := year// close_trades_after_time_of_day := timestamp(new_year,new_month,new_day,15,15)// strategy.close_all(time > close_trades_after_time_of_day)