Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Double Exponential Moving Average 8-20-63 Strategy

A Pine Script v4 strategy built on EMA (ohlc4, 8). 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 commits 100% of equity and pays 0.1% commission. 6 settings; defaults include Short 8, Source Dema 1 ohlc4 and Long 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 Double Exponential Moving Average 8-20-63 Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 6 of 6 trades.
How did Double Exponential Moving Average 8-20-63 Strategy do on BTCUSDT 1D with default settings?
+9.69%
From 26 Jan 2024 to 21 Oct 2026, over 31 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Double Exponential Moving Average 8-20-63 Strategy 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 Double Exponential Moving Average 8-20-63 Strategy have?
2
Long; Short.
Does Double Exponential Moving Average 8-20-63 Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.

BTCUSDT · 1D · default settings

  • Plot
  • 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 (6)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$106,940$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
+9.69%
$9,694.33
Buy and hold
+102.5%
same period
Closed trades
31
11 won · 20 lost
Profitable
35.5%
of closed trades
Profit factor
1.08
gross profit ÷ gross loss
Max drawdown
54.70%
−$63,926.60

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

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    3 settings have no label

    In the settings dialog short (line 17), long (line 19), long2 (line 21) 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 39, 40. 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 ema → ta.ema.
  • 2 strategy calls use the when = argument (line 39, 40). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 23: ema → ta.ema
  • Line 24: ema → ta.ema
  • Line 27: ema → ta.ema
  • Line 28: ema → ta.ema
  • Line 31: ema → ta.ema
  • Line 32: ema → ta.ema
⋯// © Noldo-//@version=4+//@version=5//Quoted by Author HighProfit⋯srcLong2 = input(close, title="Source Dema 3")-e1 = ema(srcShort, short)+e1 = ta.ema(srcShort, short)-e2 = ema(e1, short)+e2 = ta.ema(e1, short)dema1 = 2 * e1 - e2plot(dema1, color=color.green, linewidth=2)-e3 = ema(srcLong, long)+e3 = ta.ema(srcLong, long)-e4 = ema(e3, long)+e4 = ta.ema(e3, long)dema2 = 2 * e3 - e4plot(dema2, color=color.blue, linewidth=2)-e5 = ema(srcLong2, long2)+e5 = ta.ema(srcLong2, long2)-e6 = ema(e5, long2)+e6 = ta.ema(e5, long2)dema3 = 2 * e5 - e6⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 17: input() → input.int()
  • Line 18: input() → input.source()
  • Line 19: input() → input.int()
  • Line 20: input() → input.source()
  • Line 21: input() → input.int()
  • Line 22: input() → input.source()
  • Line 39: when = longC → if block
  • Line 40: when = shortC → if block
⋯         pyramiding = 0)-short = input(8, minval=1)+short = input.int(8, minval=1)-srcShort = input(ohlc4, title="Source Dema 1")+srcShort = input.source(ohlc4, title="Source Dema 1")-long = input(20, minval=1)+long = input.int(20, minval=1)-srcLong = input(low, title="Source Dema 2")+srcLong = input.source(low, title="Source Dema 2")-long2 = input(63, minval=1)+long2 = input.int(63, minval=1)-srcLong2 = input(close, title="Source Dema 3")+srcLong2 = input.source(close, title="Source Dema 3")e1 = ta.ema(srcShort, short)⋯alertshort = shortC and not shortC[1]-strategy.entry("Long" , strategy.long , when = longC ,comment="Long")+if longC+    strategy.entry("Long" , strategy.long  ,comment="Long")-strategy.entry("Short", strategy.short, when = shortC,comment="Short")+if shortC+    strategy.entry("Short", strategy.short,comment="Short")// Alerts ⋯

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L11:C9: the argument 'max_bars_back' is specified more than once. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © Noldo-//@version=5+//@version=6//Quoted by Author HighProfit⋯

Settings

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

SettingDefaultType and rangeFeeds
Short (no label in the script)8int · min 1e1 e2
Source Dema 1ohlc4sourcee1
Long (no label in the script)20int · min 1e3 e4
Source Dema 2lowsourcee3
Long2 (no label in the script)63int · min 1e5 e6
Source Dema 3closesourcee5

What it calculates

  • EMA (ema, ta.ema in v5)Source Dema 1 (ohlc4), Short (8)e1 · line 23
  • EMA (ema, ta.ema in v5)e1, Short (8)e2 · line 24
  • EMA (ema, ta.ema in v5)Source Dema 2 (low), Long (20)e3 · line 27
  • EMA (ema, ta.ema in v5)e3, Long (20)e4 · line 28
  • EMA (ema, ta.ema in v5)Source Dema 3 (close), Long2 (63)e5 · line 31
  • EMA (ema, ta.ema in v5)e5, Long2 (63)e6 · line 32

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.

ohlc4ohlc4price datashortShortsetting · 8lowlowprice datalongLongsetting · 20closecloseprice datalong2Long2setting · 63e1EMA→ e1e2EMA→ e2e3EMA→ e3e4EMA→ e4e5EMA→ e5e6EMA→ e6dema1dema1valuedema2dema2valuedema3dema3valuelongC, alertlonglongC · alertlong2 conditionsshortC, alertshortshortC · alertshort2 conditionsentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryplot:26plotplotplot:30plotplotplot:34plotplotalertcondition:42Longalertconditionalertcondition:43Shortalertcondition

Order rules

OrderFires whenBy defaultLine
Open Long longlongCdema1 > dema2 and dema1 > dema3On39
Open Short shortshortCdema1 < dema2 and dema1 < dema3On40

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Alerts

AlertCallMessageLine
Longalertcondition Buy Signal 42
Shortalertcondition Sell Signal 43

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

6/6trades 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+9.7%+102.5%3135%1.0854.7%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−6.7%+5.5%3336%0.8820.2%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+900.3%+9.8%1580%20.3933.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−14.5%+8.4%2825%0.7929.7%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+16.5%+16.7%2741%1.1358.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+8.0%+21.5%3234%1.1124.5%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−47.8%+148.3%3330%0.5075.3%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+6.3%+17.1%2941%1.1917.9%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 market1020%−$40,666.70
Sideways market1741%$43,639.60
Falling market450%$6,831.22

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

How bad could the drawdown be?

60.2%

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

0%69%
All 31 trades
SideEntryExitBarsP&L
long30 May 2024 67,652.4014 Jun 2024 66,773.0015−$1,497.08
short14 Jun 2024 66,773.0017 Jul 2024 65,044.0033$2,356.17
long17 Jul 2024 65,044.004 Aug 2024 60,698.0018−$6,933.69
short4 Aug 2024 60,698.0024 Aug 2024 64,037.2020−$5,360.26
long24 Aug 2024 64,037.207 Sep 2024 53,963.0014−$14,097.80
short7 Sep 2024 53,963.0015 Sep 2024 59,993.008−$8,478.57
long15 Sep 2024 59,993.0011 Oct 2024 60,326.4026$234.41
short11 Oct 2024 60,326.4013 Oct 2024 63,206.202−$3,296.94
long13 Oct 2024 63,206.2022 Dec 2024 97,292.0070$33,778.40
short22 Dec 2024 97,292.0020 Jan 2025 101,332.0029−$4,212.61
long20 Jan 2025 101,332.007 Feb 2025 96,554.4018−$4,541.51
short7 Feb 2025 96,554.4027 Mar 2025 86,909.2048$8,618.61
long27 Mar 2025 86,909.204 Jun 2025 105,377.0069$20,303.10
short4 Jun 2025 105,377.0011 Jun 2025 110,274.007−$5,670.93
long11 Jun 2025 110,274.0022 Jun 2025 102,120.0011−$8,437.93
short22 Jun 2025 102,120.0011 Jul 2025 116,010.0019−$14,197.00
long11 Jul 2025 116,010.001 Aug 2025 115,764.0021−$364.82
short1 Aug 2025 115,764.0014 Aug 2025 123,306.0013−$5,928.75
long14 Aug 2025 123,306.0021 Aug 2025 114,271.007−$6,187.89
short21 Aug 2025 114,271.0014 Sep 2025 115,918.0024−$1,249.93
long14 Sep 2025 115,918.0026 Sep 2025 108,994.0012−$4,615.24
short26 Sep 2025 108,994.003 Oct 2025 120,529.007−$7,579.22
long3 Oct 2025 120,529.0016 Oct 2025 110,763.0013−$5,196.99
short16 Oct 2025 110,763.0010 Dec 2025 92,678.8055$9,273.39
long10 Dec 2025 92,678.8030 Jan 2026 84,650.2051−$5,905.61
short30 Jan 2026 84,650.204 Mar 2026 68,338.0033$11,608.50
long4 Mar 2026 68,338.0021 May 2026 77,552.2078$9,606.90
short21 May 2026 77,552.206 Jul 2026 63,650.0046$14,555.00
long6 Jul 2026 63,650.0018 Sep 2026 76,417.0074$19,154.10
short18 Sep 2026 76,417.0020 Sep 2026 81,250.002−$7,558.50
long20 Sep 2026 81,250.0010 Oct 2026 82,635.6020$1,626.79

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 Exponential Moving Average 8-20-63 Strategy this page—v4 strategy+9.7%3154.7%
EMA Slope AyE by fajardoarelysemav4 strategyNo trades on this market
ROoT by realisticDove62527emav5 strategy−4.7%2259.4%
sachin5986 by mohitesachin78emav4 strategy+32.1%3517.6%
sonu1997 by Sonu1997emav4 strategy+960.7%21,103.8%
Moving Average Crossover by Muh4mm4demav4 strategy+19,990.1%301,274.2%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 9 msYes 1,000 bars in 39 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/// © Noldo//@version=4//Quoted by Author HighProfit//Lead-Instrategy("Double Exponential Moving Average 8-20-63 Strategy",          shorttitle="DEMA-8-20-63",          overlay=true,         max_bars_back = 5000,         initial_capital=100000,          max_bars_back = 5000,         default_qty_type=strategy.percent_of_equity,          default_qty_value=100,          commission_type=strategy.commission.percent,          commission_value=0.1,         pyramiding = 0)short = input(8, minval=1)srcShort = input(ohlc4, title="Source Dema 1")long = input(20, minval=1)srcLong = input(low, title="Source Dema 2")long2 = input(63, minval=1)srcLong2 = input(close, title="Source Dema 3")e1 = ema(srcShort, short)e2 = ema(e1, short)dema1 = 2 * e1 - e2plot(dema1, color=color.green, linewidth=2)e3 = ema(srcLong, long)e4 = ema(e3, long)dema2 = 2 * e3 - e4plot(dema2, color=color.blue, linewidth=2)e5 = ema(srcLong2, long2)e6 = ema(e5, long2)dema3 = 2 * e5 - e6plot(dema3, color=color.black, linewidth=2)longC  = dema1 > dema2 and dema1 > dema3shortC = dema1 < dema2 and dema1 < dema3 alertlong  = longC and  not longC[1]alertshort = shortC and not shortC[1]strategy.entry("Long" , strategy.long , when = longC ,comment="Long")strategy.entry("Short", strategy.short, when = shortC,comment="Short")// Alerts alertcondition(longC  , title='Long' , message=' Buy  Signal ')alertcondition(shortC , title='Short', message=' Sell Signal ')