The Double Exponential Moving Average (DEMA) was developed by Patrick Mulloy in 1994 with a specific goal: keep the smoothness of an EMA while removing most of the lag. The trick was nesting EMAs and using a clever subtraction step. The result is a moving average that reacts to trend changes 1–3 bars earlier than the equivalent EMA on daily Indian-index charts, with comparable smoothness in trends.
This guide walks through what DEMA is, derives the formula, computes a worked example, and explains when DEMA earns its keep over EMA, HMA, or TEMA on NIFTY 50 and BANK NIFTY.
The core idea — lag and how to remove it
Every standard moving average lags real price moves. The lag scales with the period: a 50-EMA lags by roughly 25 bars at trend changes. There are two ways to reduce lag:
- Shorten the period. This works but increases noise — a 5-EMA reacts fast but whipsaws in chop.
- Subtract a slower-lagging series from a faster-lagging series. The over-correction cancels most of the lag without shortening the period.
Patrick Mulloy’s DEMA uses approach #2. By computing an EMA, then computing an EMA of that EMA (which lags even more), then subtracting the second from twice the first, you produce a series whose lag is approximately the negative of the original EMA’s lag — i.e., the lag has been cancelled.
EMA1 = EMA(P, n)
EMA2 = EMA(EMA1, n)
DEMA = 2 × EMA1 − EMA2
EMA1 is the standard n-period EMA of closing prices. EMA2 is the n-period EMA of EMA1 — a doubly smoothed series that lags both noise and trend. The subtraction step removes the lag without restoring the noise.
For an EMA(P, n) with smoothing factor α = 2/(n+1), both EMA1 and EMA2 use the same α. The recursion for each is identical to the standard EMA — the only addition is that EMA2 takes EMA1 (not P) as its input.
A worked example — DEMA(10) on NIFTY 50
Suppose you have 30 daily closes of NIFTY 50. To compute DEMA(10):
Step 1. Compute EMA(P, 10) for every bar where there are at least 10 closes. The smoothing factor is α = 2/11 ≈ 0.1818. Each new EMA value blends 18.18% of today’s close with 81.82% of yesterday’s EMA — see our EMA formula post for the full derivation.
Step 2. Compute EMA(EMA1, 10) using the EMA1 series from step 1 as input. Same α, same recursion. The output is a smoother, more lagged version of EMA1.
Step 3. For every bar where both EMA1 and EMA2 are defined, compute 2 × EMA1 − EMA2. This is the DEMA value.
For example, if EMA1 today = 24,360 and EMA2 today = 24,300, then DEMA = 2 × 24,360 − 24,300 = 48,720 − 24,300 = 24,420. The DEMA value (24,420) sits ahead of EMA1 (24,360) — exactly what we wanted.
How much lag does DEMA remove?
For an n-period EMA with smoothing factor α = 2/(n+1), the effective lag (center of mass of the weighting) is approximately (n−1)/2. For a 10-EMA, that is about 4.5 bars; for a 50-EMA, about 24.5 bars.
DEMA’s lag is approximately the negative of EMA’s lag, meaning DEMA leads price by a small amount in steady trends. In practice, the effective DEMA lag is close to zero — somewhere between −1 and +1 bar in most equity data. That is the difference DEMA achieves over EMA: a 5-bar lag advantage on a 10-period MA.
Importantly, DEMA does not “predict” the future. The lead it generates is a mathematical effect of the subtraction step, not foresight. In a sudden price spike, DEMA reacts fast — but it has no information that EMA does not also have. The advantage shows up at trend changes, where DEMA flips on or near the actual turn while EMA flips a few bars later.
DEMA vs HMA — both are lag-reducing tricks
DEMA and HMA share the same core idea: subtract a slower-lagging series from a faster-lagging one to cancel lag, then optionally re-smooth. The differences are in the construction:
In practice, HMA (with its final √n smoothing) is slightly cleaner than DEMA in noisy markets. DEMA is slightly faster on the leading bar. For NIFTY 50 daily trend definition, the two produce very similar curves — pick based on which one your charting platform implements better.
DEMA vs EMA — when each wins
DEMA wins when:
- You want to catch trend changes 1-3 bars earlier than EMA at the same period.
- The instrument is reasonably trend-following (NIFTY 50 in trending phases, single stocks with clean direction).
- You can tolerate slightly more sensitivity to single-bar moves.
EMA wins when:
- You want maximum smoothness for trend definition.
- The instrument is choppy or news-driven (BANK NIFTY around RBI policy days, single stocks around earnings).
- You combine the moving average with a slow filter — in which case the EMA’s lag is less of a problem.
For traders who already use 50-EMA on NIFTY daily as a regime filter, swapping in 50-DEMA produces a fractionally faster filter with comparable behaviour. Most discretionary traders cannot tell the difference visually unless they overlay both lines.
DEMA vs TEMA — pushing the trick further
If subtracting once removes one layer of lag, why not subtract twice? That is the idea behind TEMA (Triple Exponential Moving Average):
TEMA = 3 × EMA1 − 3 × EMA2 + EMA3
Where EMA1 = EMA(P, n), EMA2 = EMA(EMA1, n), EMA3 = EMA(EMA2, n). TEMA removes two layers of lag and is correspondingly faster than DEMA.
The trade-off compounds: TEMA is more sensitive to noise than DEMA, which is more sensitive than EMA. For most traders, DEMA hits the sweet spot — fast enough to feel modern, smooth enough to be usable. TEMA is for situations where lag is genuinely intolerable. See our upcoming TEMA guide for the details.
Common DEMA periods on Indian indices
- 9-DEMA / 14-DEMA on 5-min and 15-min — intraday momentum
- 21-DEMA on 15-min — intraday trend bias
- 50-DEMA on daily — primary trend filter (a faster alternative to 50-EMA)
- 100-DEMA / 200-DEMA on daily — long-term filters
A practical observation: 50-DEMA on NIFTY daily flips, on average, 1-2 trading days before 50-EMA at trend changes. Over 5 years, that adds up to 8-12 fewer trades caught at the bad end of a turn — a modest but consistent edge.
Implementation
In Pine Script (TradingView):
//@version=5
indicator("DEMA", overlay=true)
length = input.int(50, title="Period")
ema1 = ta.ema(close, length)
ema2 = ta.ema(ema1, length)
dema = 2 * ema1 - ema2
plot(dema, color=color.orange, linewidth=2)
In Python / pandas:
import pandas as pd
def dema(prices: pd.Series, n: int) -> pd.Series:
ema1 = prices.ewm(span=n, adjust=False).mean()
ema2 = ema1.ewm(span=n, adjust=False).mean()
return 2 * ema1 - ema2
Three lines, including the def. Most charting platforms have DEMA built in.
Putting it together
DEMA is EMA with one layer of lag removed via a clever subtraction step. It reacts to trend changes faster than EMA, stays nearly as smooth, and has been used by trend-followers since Patrick Mulloy published it in 1994. For NIFTY 50 traders who like EMA as a trend filter but find it slightly slow, DEMA is a clean upgrade. For traders who already use HMA, DEMA does roughly the same job — pick whichever your charting platform implements more accurately.
As always, the moving average is one ingredient. Pair DEMA with the regime classifier, whipsaw tracker, and multi-timeframe alignment tools on emaindicator.com to filter trades to the contexts where DEMA is most reliable.
Frequently asked questions
- What is the Double Exponential Moving Average?
- DEMA is a moving average defined as 2 × EMA(P, n) − EMA(EMA(P, n), n). It was developed by Patrick Mulloy in 1994 as a way to retain the smoothness of EMA while removing most of the lag inherent in any moving-average calculation. The 'double' refers to using two nested EMAs.
- What is the formula for DEMA?
- DEMA = 2 × EMA(P, n) − EMA(EMA(P, n), n). Compute the n-period EMA of price. Then compute the n-period EMA of that EMA series. Subtract the second from twice the first. The result leads price by approximately the same amount that the original EMA lagged.
- Is DEMA better than EMA?
- DEMA reacts to trend changes earlier than EMA at the same period — usually by 1-3 bars on daily charts. The trade-off is that DEMA is slightly more sensitive to single-bar volatility because the lag-removal step amplifies the effect of fresh data. For trend-following with quick exits, DEMA can be preferable; for slower trend definition, EMA is steadier.
- What is the difference between DEMA and TEMA?
- TEMA (Triple Exponential Moving Average) extends the same idea by one more layer: TEMA = 3 × EMA − 3 × EMA(EMA) + EMA(EMA(EMA)). DEMA removes one layer of lag, TEMA removes two. TEMA is even faster than DEMA but also more sensitive to noise — the trade-off compounds with each additional EMA in the chain.
- What are the best DEMA settings for trading NIFTY?
- On NIFTY 50 daily, common DEMA periods are 9, 14, and 21 for intraday signals; 50 for swing-trade trend; 100 or 200 for long-term filter. As with any moving average, shorter periods give faster but noisier signals. DEMA at 21 on the 15-minute chart is a popular intraday setting for Indian-index momentum traders.
More in Moving Averages: The Complete Guide for NIFTY & BANKNIFTY Traders
Related on emaindicator.com