Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

5-10-20 Cross

A Pine Script v4 strategy built on Supertrend (2, 14) and EMA (src, 5). It has 2 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. 5 settings; defaults include EMA 1 5, EMA 2 10 and EMA 3 20.

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 5-10-20 Cross repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 7 of 7 trades.
How did 5-10-20 Cross do on BTCUSDT 1D with default settings?
+35.97%
From 26 Jan 2024 to 21 Oct 2026, over 35 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can 5-10-20 Cross 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 5-10-20 Cross use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does 5-10-20 Cross run in Zeal Terminal?
Yes
It compiles in 17 ms and runs 1,000 bars in 65 ms, in the browser.

BTCUSDT · 1D · default settings

  • EMA1
  • EMA2
  • EMA3
  • Plot
  • Plot
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (5)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$132,886$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots.
Net profit
+35.97%
$35,971.60
Buy and hold
+102.5%
same period
Closed trades
35
13 won · 22 lost
Profitable
37.1%
of closed trades
Profit factor
1.31
gross profit ÷ gross loss
Max drawdown
51.16%
−$62,524.00

One run with the author's default settings, $100,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

    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

    2 settings have no label

    In the settings dialog mult (line 9), len (line 10) 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.

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, ema → ta.ema.

v4 → v5

Verified

Same 35 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 9: input(type = input.float) → input.float()
  • Line 10: input(type = input.integer) → input.int()
  • Line 11: supertrend → ta.supertrend
  • Line 12: ema → ta.ema
  • Line 13: ema → ta.ema
  • Line 14: ema → ta.ema
⋯// © aadilpatel07-//@version=4+//@version=5strategy("5-10-20 Cross", overlay=true)⋯len3 = input(20, minval=1, title="EMA 3")-mult = input(type=input.float, defval=2)+mult = input.float(defval=2)-len = input(type=input.integer, defval=14)+len = input.int(defval=14)-[superTrend, dir] = supertrend(mult, len)+[superTrend, dir] = ta.supertrend(mult, len)-ema1 = ema(src, len1)+ema1 = ta.ema(src, len1)-ema2 = ema(src, len2)+ema2 = ta.ema(src, len2)-ema3 = ema(src, len3)+ema3 = ta.ema(src, len3)//EMA Color⋯

Clean v5

VerifiedDownload the v5 script

Same 35 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 8: input() → input.int()
⋯src = close, -len1 = input(5, minval=1, title="EMA 1")+len1 = input.int(5, minval=1, title="EMA 1")-len2 = input(10, minval=1, title="EMA 2")+len2 = input.int(10, minval=1, title="EMA 2")-len3 = input(20, minval=1, title="EMA 3")+len3 = input.int(20, minval=1, title="EMA 3")mult = input.float(defval=2)⋯

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: 35 before, 146 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.

⋯// © aadilpatel07-//@version=5+//@version=6strategy("5-10-20 Cross", overlay=true)⋯

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
EMA 15int · min 1ema1
EMA 210int · min 1ema2
EMA 320int · min 1ema3
Mult (no label in the script)2floatsuperTrend dir
Len (no label in the script)14int (written input.integer)superTrend dir

What it calculates

  • Supertrend (supertrend, ta.supertrend in v5)Mult (2), Len (14)superTrend · line 11
  • Supertrend (supertrend, ta.supertrend in v5)Mult (2), Len (14)dir · line 11
  • EMA (ema, ta.ema in v5)src, EMA 1 (5)ema1 · line 12
  • EMA (ema, ta.ema in v5)src, EMA 2 (10)ema2 · line 13
  • EMA (ema, ta.ema in v5)src, EMA 3 (20)ema3 · line 14

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.

high · low · closehigh · low · closeprice datamultMultsetting · 2lenLensetting · 14len1EMA 1setting · 5len2EMA 2setting · 10len3EMA 3setting · 20closecloseprice datasuperTrendSupertrend→ superTrenddirSupertrend→ direma1EMA→ ema1ema2EMA→ ema2ema3EMA→ ema3srcsrcvaluelongConditionlongConditionconditionshortConditionshortConditionconditioncol1, col2, col3, colResistance, colSupportColourcol1 · col2 +3entry:My Long Entry IdOpen My Long Entry Idstrategy.entryentry:My Short Entry IdOpen My Short Entry Idstrategy.entryplot:20EMA1plotplot:21EMA2plotplot:22EMA3plotplot:26plotplotplot:27plotplot

Order rules

OrderFires whenBy defaultLine
Open My Long Entry Id long(longCondition)On31
Open My Short Entry Id short(shortCondition)On35

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.

7/7trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+36.0%+102.5%3537%1.3151.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−5.4%+5.5%4033%0.8816.2%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+3.2%+9.8%2938%1.642.1%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.5%+8.4%2928%1.430.4%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.0%+16.7%3345%1.080.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%3429%1.520.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.7%+148.3%2934%2.070.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.0%+17.1%3829%0.910.1%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 (EMA 1 9, EMA 2 7) made +48.8% before 26 Dec 2025 and −25.0% after it, worse than the defaults' +41.8% after. Tuning on the past did not carry forward. 44% of the 48 combinations made money in-sample and 79% out-of-sample.

Before 26 Dec 2025 · in-sample
EMA 2 ↓ · EMA 1 →345679
5−27%−27%0%+3%+14%−16%
6−12%−12%−12%0%−17%−32%
7−13%−13%−13%−13%0%+49%
9−9%−9%−9%−9%−9%0%
10−6%−6%−6%−6%−6%−6%
12+2%+2%+2%+2%+2%+2%
14+3%+3%+3%+3%+3%+3%
17+5%+5%+5%+5%+5%+5%
From 26 Dec 2025 · out-of-sample
EMA 2 ↓ · EMA 1 →345679
5+38%+38%0%−26%−23%−22%
6+39%+39%+39%0%−23%−25%
7+44%+44%+44%+44%0%−25%
9+40%+40%+40%+40%+40%0%
10+42%+42%+42%+42%+42%+42%
12+43%+43%+43%+43%+43%+43%
14+35%+35%+35%+35%+35%+35%
17+34%+34%+34%+34%+34%+34%

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 barsTradesWonP&L
Rising market1436%−$12,188.00
Sideways market1540%$37,813.50
Falling market633%$10,346.00

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

48.0%

The 95th percentile of the worst drawdown when the same 35 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 23.5% to 48.0%; the tick is what actually happened, 40.4%. Order luck alone moves it this much.

0%55%
All 35 trades
SideEntryExitBarsP&L
long15 Feb 2024 51,795.2014 Apr 2024 63,924.5059$12,129.30
short14 Apr 2024 63,924.5017 May 2024 65,235.2033−$1,310.69
long17 May 2024 65,235.2015 Jun 2024 66,044.0029$808.78
short15 Jun 2024 66,044.0017 Jul 2024 65,044.0032$999.99
long17 Jul 2024 65,044.004 Aug 2024 60,698.0018−$4,346.01
short4 Aug 2024 60,698.0024 Aug 2024 64,037.2020−$3,339.25
long24 Aug 2024 64,037.201 Sep 2024 58,974.008−$5,063.24
short1 Sep 2024 58,974.0018 Sep 2024 60,314.0017−$1,339.99
long18 Sep 2024 60,314.0010 Oct 2024 60,636.0022$322.02
short10 Oct 2024 60,636.0015 Oct 2024 66,084.005−$5,447.99
long15 Oct 2024 66,084.0024 Dec 2024 94,881.5070$28,797.50
short24 Dec 2024 94,881.507 Jan 2025 102,236.0014−$7,354.13
long7 Jan 2025 102,236.0010 Jan 2025 92,552.503−$9,683.11
short10 Jan 2025 92,552.5017 Jan 2025 99,987.307−$7,434.81
long17 Jan 2025 99,987.306 Feb 2025 96,612.4020−$3,374.86
short6 Feb 2025 96,612.4022 Apr 2025 87,516.2075$9,096.22
long22 Apr 2025 87,516.207 Jun 2025 104,288.0046$16,772.20
short7 Jun 2025 104,288.0010 Jun 2025 110,263.003−$5,974.59
long10 Jun 2025 110,263.0021 Jun 2025 103,298.0011−$6,965.04
short21 Jun 2025 103,298.0027 Jun 2025 106,947.006−$3,649.08
long27 Jun 2025 106,947.003 Aug 2025 112,546.0037$5,599.29
short3 Aug 2025 112,546.0011 Aug 2025 119,294.008−$6,747.92
long11 Aug 2025 119,294.0020 Aug 2025 112,873.009−$6,421.32
short20 Aug 2025 112,873.0013 Sep 2025 116,029.0024−$3,156.46
long13 Sep 2025 116,029.0026 Sep 2025 108,994.0013−$7,034.92
short26 Sep 2025 108,994.002 Oct 2025 118,595.006−$9,600.50
long2 Oct 2025 118,595.0014 Oct 2025 115,166.0012−$3,428.99
short14 Oct 2025 115,166.006 Jan 2026 93,859.7084$21,306.30
long6 Jan 2026 93,859.7023 Jan 2026 89,559.7017−$4,300.03
short23 Jan 2026 89,559.7013 Mar 2026 70,541.3049$19,018.30
long13 Mar 2026 70,541.3028 Mar 2026 66,407.3015−$4,134.06
short28 Mar 2026 66,407.309 Apr 2026 71,069.9012−$4,662.65
long9 Apr 2026 71,069.9020 May 2026 76,834.4041$5,764.43
short20 May 2026 76,834.4011 Jul 2026 64,161.7052$12,672.60
long11 Jul 2026 64,161.7017 Oct 2026 81,615.9098$17,454.20

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
5-10-20 Cross this page—v4 strategy+36.0%3551.2%
JS-TechTrading- Supertrend-Strategy_Basic version by JS_TechTradingsupertrend emav5 strategy+0.1%20.0%
[VJ] Mega Supertrend for Intraday by vikrisema supertrendv4 strategyNo trades on this market
Triple Supertrend with EMA and ADX strategy by kunjandetrojasupertrend emav5 strategy−1.0%585.3%
3x Supertrend and Stoch RSI by M3RZIsupertrend emav4 strategy−128.7%24207.6%
Strategy Myth-Busting #3 - BB_BUY+SuperTrend - [MYN] by myncryptoema supertrendv5 strategy−115.1%6123.3%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 17 msYes 1,000 bars in 65 msNot measured
PineTSNo 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/// © aadilpatel07//@version=4strategy("5-10-20 Cross", overlay=true)src = close, len1 = input(5, minval=1, title="EMA 1")len2 = input(10, minval=1, title="EMA 2")len3 = input(20, minval=1, title="EMA 3")mult = input(type=input.float, defval=2)len = input(type=input.integer, defval=14)[superTrend, dir] = supertrend(mult, len)ema1 = ema(src, len1)ema2 = ema(src, len2)ema3 = ema(src, len3)//EMA Colorcol1 = color.limecol2 = color.bluecol3 = color.red//EMA Plotsplot(series=ema1,color=col1, title="EMA1")plot(series=ema2,color=col2, title="EMA2")plot(series=ema3,color=col3, title="EMA3")//plot SuperTrendcolResistance = dir == 1 and dir == dir[1] ? color.new(color.red, 100) : color.new(color.green, 100)colSupport = dir == -1 and dir == dir[1] ? color.new(color.green, 0) : color.new(color.green, 10)plot(superTrend, color = colResistance, linewidth=1)plot(superTrend, color = colSupport, linewidth=1)//longCondition = crossover(ema1, ema2) and crossover(ema1,ema3) and crossover(ema2,ema3)longCondition = ema1 > ema2 and ema1 > ema3 and ema2 > ema3 and ema2 < ema1 and dir == -1if (longCondition)    strategy.entry("My Long Entry Id", strategy.long)//shortCondition = crossover(ema2, ema1) and crossover(ema3,ema1) and crossover(ema3,ema2)shortCondition = ema1 < ema2 and ema1 < ema3 and ema2 < ema3 and ema2 > ema1 and dir == 1if (shortCondition)    strategy.entry("My Short Entry Id", strategy.short)