Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Double EMA CROSS

A Pine Script v4 strategy built on EMA (source, 25), Cross (25, 75) and Crossover (matype1, matype2). 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. 9 settings; defaults include Matype ema, Source Type close and Start Date 1.

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

BTCUSDT · 1D · default settings

  • Fast EMA
  • Slow EMA
  • 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 (9)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$111,475$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
+5.11%
$5,114.13
Buy and hold
+102.5%
same period
Closed trades
9
3 won · 6 lost
Profitable
33.3%
of closed trades
Profit factor
1.09
gross profit ÷ gross loss
Max drawdown
34.54%
−$34,536.40

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

    “Matype”, “Source Type” 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.

  • 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 matype (line 5), hidema (line 6) 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 transp =, which v5 removed line 28

    transp = on line 28, 29. v5 folds the transparency into the colour with color.new(c, transp).

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 ema → ta.ema, cross → ta.cross, crossover → ta.crossover, crossunder → ta.crossunder, sma → ta.sma.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 12: input(type = input.integer) → input.int()
  • Line 14: input(type = input.integer) → input.int()
  • Line 16: input(type = input.integer) → input.int()
  • Line 24: ema → ta.ema
  • Line 25: ema → ta.ema
6 more edits
  • Line 27: cross → ta.cross
  • Line 28: transp = 0 → color.new(color.green, 0)
  • Line 29: transp = 0 → color.new(color.red, 0)
  • Line 32: crossover → ta.crossover
  • Line 35: crossunder → ta.crossunder
  • Line 42: sma → ta.sma
⋯// Double EMA CROSS By © EmreE (Emre Ertürk) Also thx for KivancOzbilgic color based bars-//@version=4+//@version=5strategy(title="Double EMA CROSS", shorttitle="DEC", overlay=true)⋯// Configure backtest start date with inputs-startDate = input(title="Start Date", type=input.integer,+startDate = input.int(title="Start Date",     defval=1, minval=1, maxval=231)-startMonth = input(title="Start Month", type=input.integer,+startMonth = input.int(title="Start Month",     defval=1, minval=1, maxval=12) -startYear = input(title="Start Year", type=input.integer,+startYear = input.int(title="Start Year",     defval=2020, minval=1800, maxval=2100)⋯slow = input(75, title="Slow")-matype1=ema(source, fast)+matype1=ta.ema(source, fast)-matype2=ema(source, slow)+matype2=ta.ema(source, slow)signalcolor = source > matype2 ? color.blue : color.red-signal = cross(fast, slow) +signal = ta.cross(fast, slow) -hizliema=plot(hidema ? na : matype1, color=color.green, linewidth=2,transp=0, title="Fast EMA")+hizliema=plot(hidema ? na : matype1, color=color.new(color.green, 0), linewidth=2, title="Fast EMA")-yavasema=plot(hidema ? na : matype2, color=color.red, linewidth=2,transp=0, title="Slow EMA")+yavasema=plot(hidema ? na : matype2, color=color.new(color.red, 0), linewidth=2, title="Slow EMA")//kesisme=plot(signal, style=cross, color=signalcolor, linewidth=5, title="Kesişme") -longCondition = crossover(matype1, matype2)+longCondition = ta.crossover(matype1, matype2)if (afterStartDate and longCondition)    strategy.entry("Long", strategy.long)-shortCondition = crossunder(matype1, matype2)+shortCondition = ta.crossunder(matype1, matype2)if (afterStartDate and shortCondition)⋯length=input(21, "length", minval=1)-avrg=sma(volume,length)+avrg=ta.sma(volume,length)vold1 = volume > avrg*1.5 and close<open⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 5: input() → input.string()
  • Line 6: input() → input.bool()
  • Line 7: input() → input.source()
  • Line 22: input() → input.int()
  • Line 23: input() → input.int()
  • Line 41: input() → input.int()
⋯strategy(title="Double EMA CROSS", shorttitle="DEC", overlay=true)-matype = input("ema")+matype = input.string("ema")-hidema = input(false)+hidema = input.bool(false)-sourcetype = input(close, title="Source Type")+sourcetype = input.source(close, title="Source Type")source=close⋯     startYear, startMonth, startDate, 0, 0))-fast = input(25, title="Fast")+fast = input.int(25, title="Fast")-slow = input(75, title="Slow")+slow = input.int(75, title="Slow")matype1=ta.ema(source, fast)⋯//volume based color bars-length=input(21, "length", minval=1)+length=input.int(21, "length", minval=1)avrg=ta.sma(volume,length)⋯

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: 9 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.

⋯// Double EMA CROSS By © EmreE (Emre Ertürk) Also thx for KivancOzbilgic color based bars-//@version=5+//@version=6strategy(title="Double EMA CROSS", shorttitle="DEC", 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
Matype (no label in the script)emastringunused
Hidema (no label in the script)falseboolFast EMA Slow EMA
Source Typeclosesourceunused
Start Date1int (written input.integer) · min 1 · max 231afterStartDate
Start Month1int (written input.integer) · min 1 · max 12afterStartDate
Start Year2020int (written input.integer) · min 1800 · max 2100afterStartDate
Fast25intmatype1 signal
Slow75intmatype2 signal
length21int · min 1avrg

What it calculates

  • EMA (ema, ta.ema in v5)source, Fast (25)matype1 · line 24
  • EMA (ema, ta.ema in v5)source, Slow (75)matype2 · line 25
  • Cross (cross, ta.cross in v5)Fast (25), Slow (75)signal · line 27
  • Crossover (crossover, ta.crossover in v5)matype1, matype2longCondition · line 32
  • Crossunder (crossunder, ta.crossunder in v5)matype1, matype2shortCondition · line 35
  • SMA (sma, ta.sma in v5)volume, length (21)avrg · line 42

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.

fastFastsetting · 25slowSlowsetting · 75volumevolumeprice datalengthlengthsetting · 21closecloseprice datatimetimeprice datastartYearStart Yearsetting · 2020startMonthStart Monthsetting · 1startDateStart Datesetting · 1openopenprice datamatype1EMA→ matype1matype2EMA→ matype2signalCross→ signallongConditionCrossover→ longConditionshortConditionCrossunder→ shortConditionavrgSMA→ avrgsourcesourcevalueacacvalueafterStartDateafterStartDateconditionvold1, vold2, vold3, volu1, volu2, volu3vold1 · vold2 +46 conditionssignalcolor, cold1, cold2, cold3, colu1, colu2, colu3Coloursignalcolor · cold1 +5entry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryplot:28Fast EMAplotplot:29Slow EMAplotbarcolor:56barcolorbarcolor

Order rules

OrderFires whenBy defaultLine
Open Long long(afterStartDate and longCondition)On34
Open Short short(afterStartDate and shortCondition)On37

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.

2/2trades 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+5.1%+102.5%933%1.0934.5%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+3.2%+5.5%1040%1.276.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+1.3%+9.8%933%1.602.2%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.1%+8.4%922%1.330.2%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.0%+16.7%1331%0.830.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%1323%1.220.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%922%1.020.4%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.1%+17.1%1118%0.600.2%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 barsTradesWonP&L
Rising market0—$0.00
Sideways market933%$5,114.13
Falling market0—$0.00

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

How bad could the drawdown be?

44.0%

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

0%51%
All 9 trades
SideEntryExitBarsP&L
short29 Jun 2024 60,427.8026 Jul 2024 65,799.9027−$5,372.11
long26 Jul 2024 65,799.906 Aug 2024 54,018.8011−$11,781.10
short6 Aug 2024 54,018.8027 Sep 2024 65,174.0052−$11,155.20
long27 Sep 2024 65,174.0027 Feb 2025 84,250.10153$19,076.10
short27 Feb 2025 84,250.1028 Apr 2025 93,749.3060−$9,499.20
long28 Apr 2025 93,749.3020 Oct 2025 108,643.00175$14,893.50
short20 Oct 2025 108,643.0025 Apr 2026 77,437.10187$31,205.60
long25 Apr 2026 77,437.103 Jun 2026 66,760.8039−$10,676.30
short3 Jun 2026 66,760.8022 Aug 2026 78,338.0080−$11,577.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
Double EMA CROSS this page—v4 strategy+5.1%934.5%
EMA Stoch Strategy For ProfitView by treigensma ema crossv5 strategy−69.8%580.6%
MACD Long Strat by TheGrindTodayema smav4 strategy+24.0%7920.1%
Stock trending strategy by exlux99ema smav4 strategy+35.3%2114.7%
4-Hour Stochastic EMA Trend by slymnturkogluema smav4 strategyNo trades on this market
4X EMA and volume strategy by SoftKill21ema smav4 strategy+1.8%325.8%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 9 msYes 1,000 bars in 40 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/// Double EMA CROSS By © EmreE (Emre Ertürk) Also thx for KivancOzbilgic color based bars//@version=4strategy(title="Double EMA CROSS", shorttitle="DEC", overlay=true)matype = input("ema")hidema = input(false)sourcetype = input(close, title="Source Type")source=close // STEP 1:// Configure backtest start date with inputsstartDate = input(title="Start Date", type=input.integer,     defval=1, minval=1, maxval=231)startMonth = input(title="Start Month", type=input.integer,     defval=1, minval=1, maxval=12) startYear = input(title="Start Year", type=input.integer,     defval=2020, minval=1800, maxval=2100)// STEP 2:// See if this bar's time happened on/after start dateafterStartDate = (time >= timestamp(syminfo.timezone,     startYear, startMonth, startDate, 0, 0))fast = input(25, title="Fast")slow = input(75, title="Slow")matype1=ema(source, fast)matype2=ema(source, slow)signalcolor = source > matype2 ? color.blue : color.redsignal = cross(fast, slow) hizliema=plot(hidema ? na : matype1, color=color.green, linewidth=2,transp=0, title="Fast EMA")yavasema=plot(hidema ? na : matype2, color=color.red, linewidth=2,transp=0, title="Slow EMA")//kesisme=plot(signal, style=cross, color=signalcolor, linewidth=5, title="Kesişme") longCondition = crossover(matype1, matype2)if (afterStartDate and longCondition)    strategy.entry("Long", strategy.long)shortCondition = crossunder(matype1, matype2)if (afterStartDate and shortCondition)    strategy.entry("Short", strategy.short)    //--------------------------------------------------------//volume based color barslength=input(21, "length", minval=1)avrg=sma(volume,length)vold1 = volume > avrg*1.5 and close<openvold2 = volume >= avrg*0.5 and volume<=avrg*1.5 and close<openvold3 = volume < avrg *0.5 and close<openvolu1 = volume > avrg*1.5 and close>openvolu2 = volume >= avrg*0.5 and volume<=avrg*1.5 and close>openvolu3 = volume< avrg*0.5 and close>opencold1=#800000cold2=#FF0000cold3=color.orangecolu1=#006400colu2=color.limecolu3=#7FFFD4ac = vold1 ? cold1 : vold2 ? cold2 : vold3 ? cold3 : volu1 ? colu1 : volu2 ? colu2 : volu3 ? colu3 : nabarcolor(ac)