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
- 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
VerifiedSame 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⋯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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Short (no label in the script) | 8 | int · min 1 | e1 e2 |
| Source Dema 1 | ohlc4 | source | e1 |
| Long (no label in the script) | 20 | int · min 1 | e3 e4 |
| Source Dema 2 | low | source | e3 |
| Long2 (no label in the script) | 63 | int · min 1 | e5 e6 |
| Source Dema 3 | close | source | e5 |
What it calculates
- EMA (
ema,ta.emain v5)Source Dema 1 (ohlc4), Short (8)e1 · line 23 - EMA (
ema,ta.emain v5)e1, Short (8)e2 · line 24 - EMA (
ema,ta.emain v5)Source Dema 2 (low), Long (20)e3 · line 27 - EMA (
ema,ta.emain v5)e3, Long (20)e4 · line 28 - EMA (
ema,ta.emain v5)Source Dema 3 (close), Long2 (63)e5 · line 31 - EMA (
ema,ta.emain 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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Long long | longCdema1 > dema2 and dema1 > dema3 | On | 39 |
| Open Short short | shortCdema1 < dema2 and dema1 < dema3 | On | 40 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Alerts
| Alert | Call | Message | Line |
|---|---|---|---|
| Long | alertcondition | Buy Signal | 42 |
| Short | alertcondition | Sell Signal | 43 |
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 | +9.7% | +102.5% | 31 | 35% | 1.08 | 54.7% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −6.7% | +5.5% | 33 | 36% | 0.88 | 20.2% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +900.3% | +9.8% | 15 | 80% | 20.39 | 33.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −14.5% | +8.4% | 28 | 25% | 0.79 | 29.7% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +16.5% | +16.7% | 27 | 41% | 1.13 | 58.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +8.0% | +21.5% | 32 | 34% | 1.11 | 24.5% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −47.8% | +148.3% | 33 | 30% | 0.50 | 75.3% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +6.3% | +17.1% | 29 | 41% | 1.19 | 17.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 10 | 20% | −$40,666.70 |
| Sideways market | 17 | 41% | $43,639.60 |
| Falling market | 4 | 50% | $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.
All 31 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 30 May 2024 67,652.40 | 14 Jun 2024 66,773.00 | 15 | −$1,497.08 |
| short | 14 Jun 2024 66,773.00 | 17 Jul 2024 65,044.00 | 33 | $2,356.17 |
| long | 17 Jul 2024 65,044.00 | 4 Aug 2024 60,698.00 | 18 | −$6,933.69 |
| short | 4 Aug 2024 60,698.00 | 24 Aug 2024 64,037.20 | 20 | −$5,360.26 |
| long | 24 Aug 2024 64,037.20 | 7 Sep 2024 53,963.00 | 14 | −$14,097.80 |
| short | 7 Sep 2024 53,963.00 | 15 Sep 2024 59,993.00 | 8 | −$8,478.57 |
| long | 15 Sep 2024 59,993.00 | 11 Oct 2024 60,326.40 | 26 | $234.41 |
| short | 11 Oct 2024 60,326.40 | 13 Oct 2024 63,206.20 | 2 | −$3,296.94 |
| long | 13 Oct 2024 63,206.20 | 22 Dec 2024 97,292.00 | 70 | $33,778.40 |
| short | 22 Dec 2024 97,292.00 | 20 Jan 2025 101,332.00 | 29 | −$4,212.61 |
| long | 20 Jan 2025 101,332.00 | 7 Feb 2025 96,554.40 | 18 | −$4,541.51 |
| short | 7 Feb 2025 96,554.40 | 27 Mar 2025 86,909.20 | 48 | $8,618.61 |
| long | 27 Mar 2025 86,909.20 | 4 Jun 2025 105,377.00 | 69 | $20,303.10 |
| short | 4 Jun 2025 105,377.00 | 11 Jun 2025 110,274.00 | 7 | −$5,670.93 |
| long | 11 Jun 2025 110,274.00 | 22 Jun 2025 102,120.00 | 11 | −$8,437.93 |
| short | 22 Jun 2025 102,120.00 | 11 Jul 2025 116,010.00 | 19 | −$14,197.00 |
| long | 11 Jul 2025 116,010.00 | 1 Aug 2025 115,764.00 | 21 | −$364.82 |
| short | 1 Aug 2025 115,764.00 | 14 Aug 2025 123,306.00 | 13 | −$5,928.75 |
| long | 14 Aug 2025 123,306.00 | 21 Aug 2025 114,271.00 | 7 | −$6,187.89 |
| short | 21 Aug 2025 114,271.00 | 14 Sep 2025 115,918.00 | 24 | −$1,249.93 |
| long | 14 Sep 2025 115,918.00 | 26 Sep 2025 108,994.00 | 12 | −$4,615.24 |
| short | 26 Sep 2025 108,994.00 | 3 Oct 2025 120,529.00 | 7 | −$7,579.22 |
| long | 3 Oct 2025 120,529.00 | 16 Oct 2025 110,763.00 | 13 | −$5,196.99 |
| short | 16 Oct 2025 110,763.00 | 10 Dec 2025 92,678.80 | 55 | $9,273.39 |
| long | 10 Dec 2025 92,678.80 | 30 Jan 2026 84,650.20 | 51 | −$5,905.61 |
| short | 30 Jan 2026 84,650.20 | 4 Mar 2026 68,338.00 | 33 | $11,608.50 |
| long | 4 Mar 2026 68,338.00 | 21 May 2026 77,552.20 | 78 | $9,606.90 |
| short | 21 May 2026 77,552.20 | 6 Jul 2026 63,650.00 | 46 | $14,555.00 |
| long | 6 Jul 2026 63,650.00 | 18 Sep 2026 76,417.00 | 74 | $19,154.10 |
| short | 18 Sep 2026 76,417.00 | 20 Sep 2026 81,250.00 | 2 | −$7,558.50 |
| long | 20 Sep 2026 81,250.00 | 10 Oct 2026 82,635.60 | 20 | $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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Double Exponential Moving Average 8-20-63 Strategy this page | — | v4 strategy | +9.7% | 31 | 54.7% |
| EMA Slope AyE by fajardoarelys | ema | v4 strategy | No trades on this market | ||
| ROoT by realisticDove62527 | ema | v5 strategy | −4.7% | 225 | 9.4% |
| sachin5986 by mohitesachin78 | ema | v4 strategy | +32.1% | 35 | 17.6% |
| sonu1997 by Sonu1997 | ema | v4 strategy | +960.7% | 2 | 1,103.8% |
| Moving Average Crossover by Muh4mm4d | ema | v4 strategy | +19,990.1% | 30 | 1,274.2% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 9 ms | Yes 1,000 bars in 39 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/// © 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 ')