ForexBestRobots.comCompare EAs →
EN

DEMA · TWO EMA STAGES · REAL FOREX CHARTS

DEMA in Forex: Double Smoothing, Initialization and Real Charts

Follow the two EMA stages on historical USD/JPY candles, compare starting values and inspect what a price cross actually tells you.

Real USD/JPY H1, ending 2024-02-02 14:00 UTC. EMA1 and EMA2 use period 20; DEMA=2×EMA1−EMA2. The window ends at the selected candle.
Real USD/JPY H1, ending 2024-02-02 14:00 UTC. EMA1 and EMA2 use period 20; DEMA=2×EMA1−EMA2. The window ends at the selected candle.

DEMA combines an exponential moving average with an EMA of that average. Subtracting the second stage compensates for part of the lag; it does not turn the line into a forecast. This guide traces the calculation on real Forex quotes and keeps indicator readings separate from a tested trading strategy.

1. Understand the two stages

Patrick Mulloy introduced DEMA in 1994. The first stage, EMA1, smooths the chosen price. The second, EMA2, smooths EMA1 over the same period. DEMA then adds the difference EMA1−EMA2 back to EMA1. All three lines are expressed in price units; the second stage is not a second trading signal.

During a sustained rise, EMA1 will often sit above EMA2, pulling DEMA above EMA1. During a decline, the relationship can reverse. These are possible configurations, not rules that must hold on every candle. Because the formula includes subtraction, DEMA need not stay within the range of its recent input prices.

2. Calculate DEMA without confusing it with EMA2

Here C[t] is the completed H1 close and N is a number of recorded bars. Both EMA stages use α=2/(N+1), the same N and no horizontal shift. The second recurrence uses the current, newly calculated EMA1[t]. DEMA is neither EMA2 nor an EMA whose period has simply been halved.

The main calculation starts EMA1 and EMA2 at the first retained close. The alternative starts EMA1 with the arithmetic mean of the first N closes, then starts EMA2 with the mean of the first N available EMA1 values. Under that alternative, DEMA first exists on recorded bar 2N−1. Unavailable values remain blank; they are not zero.

α = 2 / (N + 1)
EMA1[t] = α × C[t] + (1−α) × EMA1[t−1]
EMA2[t] = α × EMA1[t] + (1−α) × EMA2[t−1]
DEMA[t] = 2 × EMA1[t] − EMA2[t]
DEMA[t] − EMA1[t] = EMA1[t] − EMA2[t]

3. Read the three lines on a real chart

The first example places the price candles, EMA1, EMA2 and DEMA on one scale. The numerical panel identifies the selected candle and the two intermediate values, so the displayed DEMA can be checked directly as 2×EMA1−EMA2. For USD/JPY, one pip in this guide is 0.01 JPY per USD.

DEMA being closer to the latest price in this example describes its response, not the quality of a possible entry. Price can move away from the line or cross back through it. Spread, execution and exit rules would all matter in a separate trading test.

DEMA, EMA1 and EMA2 on the same candles

Real USD/JPY H1, ending 2024-02-02 14:00 UTC. EMA1 and EMA2 use period 20; DEMA=2×EMA1−EMA2. The window ends at the selected candle.
Real USD/JPY H1, ending 2024-02-02 14:00 UTC. EMA1 and EMA2 use period 20; DEMA=2×EMA1−EMA2. The window ends at the selected candle.

Interval end · UTC: 2024-02-02T14:00:00Z · Close: 147.950

Initialization methodEMA1(20)EMA2(20)DEMA(20)
First retained close146.664690146.577852146.751528
Staged SMA146.664690146.577852146.751528

4. Distinguish a fresh cross from continued positioning

A fresh upward price cross means C[t−1]≤DEMA[t−1] and C[t]>DEMA[t]. A fresh downward cross uses C[t−1]≥DEMA[t−1] and C[t]<DEMA[t]. Merely remaining above the line is not a new upward cross. The explorer evaluates these conditions before display rounding and does not bridge a missing or incomplete hour.

The second example is the first eligible downward recross within four recorded bars after an upward cross. Both appear on historical completed candles. The recross illustrates why a responsive line can change direction quickly; no entry, stop, target or profit is inferred from the picture.

An upward cross followed by a downward recross

Real USD/JPY H1, ending 2024-02-01 14:00 UTC. A downward recross follows an upward cross within four recorded candles. These are indicator events, without a simulated trade result.
Real USD/JPY H1, ending 2024-02-01 14:00 UTC. A downward recross follows an upward cross within four recorded candles. These are indicator events, without a simulated trade result.

Interval end · UTC: 2024-02-01T14:00:00Z · Close: 146.640

Initialization methodEMA1(20)EMA2(20)DEMA(20)
First retained close146.839125146.987378146.690872
Staged SMA146.839125146.987378146.690872

5. Compare initialization methods

The third example uses the same closes and N=20 with two different starting conventions. On recorded bar 39, the alternative has its first DEMA value. The panel compares both results at that same timestamp. A different history start can therefore change an early reading even when the displayed period matches.

Initialization effects tend to fade as additional observations arrive, but there is no universal warm-up count that guarantees agreement to every decimal place. The main trend and recross examples require at least 500 prior recorded candles and a 64-hour complete, consecutive display window. That is a declared selection rule, not a platform-equivalence certificate.

Same history, two initialization methods

Real USD/JPY H1, ending 2024-01-03 13:00 UTC, recorded candle 39. DEMA20 differs between first-close and staged-SMA initialization; both use the identical retained prices.
Real USD/JPY H1, ending 2024-01-03 13:00 UTC, recorded candle 39. DEMA20 differs between first-close and staged-SMA initialization; both use the identical retained prices.

Interval end · UTC: 2024-01-03T13:00:00Z · Close: 142.920

Initialization methodEMA1(20)EMA2(20)DEMA(20)
First retained close142.262922141.872387142.653457
Staged SMA142.258645141.857094142.660196

6. Change the period and check the history

Periods 10, 20 and 50 are fixed illustrations, not profit-optimized settings. Changing N changes both smoothing stages. Keep the selected candle fixed when comparing periods; otherwise a price change can be mistaken for a parameter effect. A smaller N responds more strongly to new inputs, while a longer N retains more influence from older observations.

Every recorded close updates the calculation once, including a retained partial hour. EMA states carry across gaps without inserting flat candles or resetting. Consequently 20 recorded H1 bars need not span 20 consecutive clock hours. MetaTrader 5 documents a built-in DEMA; for an MT4 custom indicator, check its code, applied price, seed, history and shift before comparing numbers.

7. Inspect the candles and calculation

Choose a period and initialization method, then move the candle slider or use Previous and Next. The chart ends at the selected candle and the table compares all three periods at that timestamp. Example buttons restore period 20 and the first-close initialization. The initialization example deliberately shows the beginning of the retained history.

The three examples follow declared chronological rules, without selecting trades by outcome. The first shows Close>DEMA>EMA1 with at least a one-pip DEMA−EMA1 gap; the second shows the first eligible recross; the third is the first alternative-seed DEMA20 value. Live candle values can change before close; these stored examples cannot establish how a broker would have executed an order.

Loading historical candles…

Interval end · UTC
—
OHLC · JPY per USD
—
Close
—
EMA1
—
EMA2
—
DEMA
—
DEMA minus EMA1 · pip
—
Close minus DEMA · pip
—
DEMA change · pip
—
First-close DEMA minus SMA-seeded DEMA · pip
—
Observed minute bars
—
Hour completeness
—
Gap before this hour
—
Recorded bars from history start
—
Gaps in retained history
—
Partial hours in retained history
—
Fresh price cross
—

Same candle · periods 10 / 20 / 50

Period · recorded barsEMA1EMA2DEMAClose − DEMA · pip

Frequently asked questions

Is DEMA the same as an EMA smoothed twice?

No. EMA2 is the twice-smoothed component. DEMA combines both stages as 2×EMA1−EMA2.

Does DEMA remove all delay and false crosses?

No. It responds differently from a single EMA, can overshoot and can cross price repeatedly. Faster response alone does not establish profitability.

Why can two DEMA indicators disagree?

Check the price source, period, seed of both stages, history start, missing bars and horizontal shift. Matching the indicator name is insufficient.

When does the SMA-initialized DEMA first become available?

With the staged convention used here, EMA1 starts on bar N and EMA2 on bar 2N−1. For N=20 the first DEMA is on recorded bar 39.

Is a price cross an instruction to trade?

It is a precisely defined indicator event. A trade still needs independently specified execution, risk and exit rules, then testing with costs.

Are the candles real and is this a backtest?

The charts use retained historical Forexite quotes. This is an indicator guide with reproducible calculations, not a trading-performance backtest.

Data, calculation choices and scope

The retained source contains 375,702 USD/JPY minute observations from Forexite’s 2024 Trade/MetaStock daily archives, reused from our earlier verified dataset. Fixed GMT+1 labels are shifted back one hour to UTC. Treating minute labels as interval ends and aggregating H1 intervals (start,end] are declared reconstruction assumptions, rather than a claim about every broker’s candle convention.

There are 6,265 recorded H1 intervals, ending from 2024-01-01 23:00 UTC through 2024-12-31 23:00 UTC: 6,178 complete hours, 87 partial hours and 52 gaps before recorded hours. All retained closes update the averages; the chart breaks across gaps, and fresh-cross labels require two complete adjacent hours. These reference quotes provide neither a complete bid/ask execution path nor a guarantee of agreement with a trading terminal.

The CSV provides every hourly candle and both initialization methods for periods 10/20/50. The method download contains the retained minute inputs, original archive URLs and checksums, calculation code and verification results. A separate raw-archive parser and high-precision calculation check the reconstruction. No simulated market candles or trading returns are added.

Primary references