DEMA indicator: how it cuts EMA lag and what a crossover test shows
DEMA removes part of an EMA's lag by adding back the gap between the EMA and the EMA of that EMA. The line turns earlier, but it also flips more often in sideways markets, so whether it helps a crossover rule is decided by the average trade after commission and slippage, not by how fast the line looks.
By Soren Huang · Published · updated · Editorial policy
Contents
- What is the DEMA indicator and how does it reduce lag?
- What is the difference between DEMA and EMA?
- Does less lag mean better signals? The lag versus noise trade-off
- How do you set DEMA parameters?
- Does a DEMA crossover strategy survive whipsaws and costs?
- How does DEMA compare with other ways to cut lag?
- Frequently asked questions
- References
What is the DEMA indicator and how does it reduce lag?
The DEMA indicator (double exponential moving average) cuts lag by taking an EMA, measuring how far that EMA trails its own smoothed copy, and adding that gap back: DEMA = 2×EMA − EMA(EMA). The line sits closer to current price than an EMA of the same length, but it flips more often in ranges, so a cost-aware crossover test decides whether it helps.
An EMA (exponential moving average) is an average of recent prices that gives the newest bar the largest weight and older bars less and less weight. Lag is the number of bars by which a smoothed line trails the price it is averaging. Every moving average has lag because it is partly made of old prices; the moving averages encyclopedia page covers the common types.
The trick behind DEMA is to estimate the lag and subtract it. Smooth the EMA once more, and you get an EMA of the EMA that lags even further. The distance between the two is a good estimate of how much the first EMA is behind price. Add that distance on top of the EMA and the line moves forward. In the formula, EMA is the ordinary EMA of price, EMA(EMA) is the same EMA applied to that first line, and 2×EMA − EMA(EMA) is the EMA plus the gap between them. A useful picture: a runner is 10 metres behind the leader, and his shadow is 20 metres behind; if you push the runner forward by the distance to his own shadow, he lands near the leader.
One mistake to avoid: DEMA is not an EMA applied twice. An EMA of an EMA is the slow helper line inside the formula and lags more than a plain EMA, not less. The "double" in the name refers to the 2× in front of the first EMA.
What is the difference between DEMA and EMA?
At the same length, DEMA turns earlier at a reversal and hugs price more tightly, while EMA turns later and stays calmer in a sideways stretch. Both lines use the same input and the same length setting; the difference is only the correction step. That step pays off when price is trending, because the line is closer to the current move, and it costs you when price is ranging, because a line that reacts faster also reacts to noise.
| Behaviour | EMA (same length) | DEMA (same length) |
|---|---|---|
| Turn after a price reversal | Later, by several bars on a slow setting | Earlier; the correction pulls the line toward recent price |
| Distance from price in a trend | Trails well behind a steady move | Sits close to the move |
| Behaviour in a range | Crosses price rarely | Crosses price more often; each cross is a possible false signal |
| Overshoot at sharp turns | Little; the line is slow | Can overshoot past price and then snap back |
| Smoothness of the line | Smoother | Rougher at the same length |
Many traders compare the two by running them at different lengths, for example EMA(10) against DEMA(20), and conclude that DEMA is "smoother for the same speed". That comparison is fair only if you then test both at the length you would actually trade, because the setting that looks right on a chart is rarely the one that survives costs.
Does less lag mean better signals? The lag versus noise trade-off
Less lag does not mean better signals, because every bar of lag you remove adds false turns, and only the net result after costs tells you which side won. A false turn, usually called a whipsaw, is a signal that reverses within a few bars and exits at a loss. Smoothing exists to hide noise; a line that hides less noise must show more of it. This is the one claim this article rests on: the speed of the line is not the test, the average trade after commission and slippage is.
Think of a car's suspension. Stiff springs let you feel every bump in the road; soft springs let you feel the hills late. Neither setting is right for every road, and you judge the setting by how the car handles the full trip, not by how it feels over one bump. The same logic applies to any rule you make faster or stricter: the rule fires earlier on real moves, and the rule also fires more often on nothing.
Hypothetical example
Suppose an EMA crossover rule takes 100 trades in a year, 40 of them whipsaws, and the whole year nets $20,000 before costs. Switching the same rule to DEMA at the same length enters each real trend two bars earlier, worth an extra $150 on each of the 60 good trades, or $9,000. But the faster line also adds 50 more whipsaws at an average loss of $200 each, or $10,000. Before costs the DEMA version is already $1,000 behind. With a $30 round trip on each of the 50 extra trades, it is $2,500 behind. The earlier entries were real; they were just not enough to pay for the noise on this market and bar size. On a cleaner trending market the same sums could come out the other way, which is why the test is run and not assumed.
Round-trip cost is what sets the price of each extra false turn. On NQ, one tick is 0.25 index points worth $5.00, so a $30 round trip is six ticks that each whipsaw must overcome before the trade reaches zero; the futures contract calculator shows tick and point values for other contracts, and the exchange's contract page is the place to confirm them, since exchanges can change these values.
How do you set DEMA parameters?
Set the DEMA length from the holding time you want and the round-trip cost you pay, then test a band of neighbouring lengths and keep a setting that sits in a flat region of results rather than on one lucky peak. A length is the number of bars the EMA averages over; the only other input is the price series, usually the close. Because DEMA is faster than EMA, a DEMA length that behaves like your current EMA is usually longer, not the same number.
- Start from the holding time. A rule meant to hold for days on daily bars needs a length that ignores single-day noise; a rule meant for intraday bars needs a length that still ignores a few bars of chop. The intraday indicator test shows how quickly short lengths turn into cost on 5-minute bars.
- Check the cost. The shorter the length, the more trades, and each trade pays the same commission and slippage. If the gross average trade of a short setting is not several times the round trip, lengthen it before testing anything else; trading costs in backtests explains the comparison.
- Test a band, not a value. Run lengths from roughly half to double your starting point, in steps you could tell apart on a chart.
- Keep a plateau setting. A plateau is a stretch of neighbouring lengths that all produce similar net results. Pick near the middle of it. A single length that beats its neighbours by a wide margin is describing noise in that history, a point Pardo (2008) makes central to parameter evaluation.
Hypothetical example
A trader tests DEMA crossover lengths 10 to 60 on daily bars. Lengths 20, 25, 30 and 40 net between $8,000 and $10,000 after costs; length 15 nets $18,000 but lengths 10 and 20 next to it net $2,000 and $9,000. The trader keeps 30, the middle of the plateau, and writes down that 15 was rejected because its neighbours did not agree with it.
Does a DEMA crossover strategy survive whipsaws and costs?
A DEMA crossover strategy survives only if the trades that follow its earlier turns pay for the whipsaws and the round-trip cost of every trade, and the way to find out is to count the whipsaws and read the average trade after costs. A crossover rule is a rule that goes long when a fast line crosses above a slow line, or above price, and goes short or flat when it crosses back. Brock, Lakonishok and LeBaron (1992) tested moving average crossover rules on a long stock index history and found that the rules produced signals with some information before costs; what matters for you is whether that holds on your market, at your length, after your costs.
- Write the rule and the length band first. Fast line, slow line or price, long and short conditions, and the lengths you will try.
- Add commission and slippage per trade and fill on the next bar. A crossover is confirmed at the bar close; the fill belongs to the next bar's open. AlphaPrime (Valynox) charges fees and slippage inside every evaluation and fills on the next bar in its backtesting, so a crossover setting that only works with free same-bar fills never reaches the ranking.
- Run every length on the in-sample part of the history.
- Count the whipsaws and read the average trade after costs. Mark each trade that exits within a few bars at a loss. A rule where whipsaws are most of the trades and the average trade is near the round-trip cost is living on a few large winners.
- Run the kept length unchanged on the out-of-sample part.
- Accept or reject by the rule from step 1.
The report below shows what step 4 looks like on a real run. It did not test a DEMA crossover. The run tested a stand-in rule on NQ daily bars from 2019-01-02 to 2025-06-30, long and short with one contract, with $20 commission and $10 slippage per trade: a Bipower Jump Ratio rule as the only entry and exit, with no stop, no target and no filters. The candidate shown is the one the search kept out of the 1,024 it tried, chosen for its return against its drawdown. Picking the best of many after the fact flatters the result, which is exactly the effect Bailey, Borwein, López de Prado and Zhu (2014) describe, so read the numbers as an example of a report, not as money a rule earned or a reader can expect.
Source: AlphaPrime product engine (CPU), run 2026-10-31. NQ daily bars, 2019-01-02 to 2025-06-30, long and short, 1 contract, $20 commission and $10 slippage per trade.
| Number | Result |
|---|---|
| Net profit (closed trades) | $281,815 |
| Max drawdown | $62,950 |
| Trades | 151 |
| Win rate | 55.63% |
| Profit factor | 1.78 |
| Average trade | $1,866.32 |
| Time in market | 55.89% |

How to read it the way step 4 asks. The average trade of $1,866.32 is set against the $30 round trip charged on every trade: the cost is a small share of the average trade, so a modest rise in slippage would not change the sign. The 151 trades over about six and a half years on daily bars is a small sample for a per-trade figure; the in-sample versus out-of-sample guide explains why a few hundred out-of-sample trades are a safer base. The profit factor of 1.78 (gross wins divided by gross losses) and the 55.63% win rate say the result is not carried by one trade in ten; the max drawdown of $62,950 against the net profit of $281,815 is the ratio the search selected for, so it is the number most flattered by the selection. A DEMA crossover test on the same data would produce the same report, and the same reading would apply.

How does DEMA compare with other ways to cut lag?
DEMA is one of several tools that trade smoothness for speed, each with a different trick and a different cost, and the same cost-aware crossover test puts all of them on one scale. TEMA (triple exponential moving average) applies the DEMA correction a second time, which removes more lag and admits more noise. The Hull moving average combines weighted averages of half and full length so the line reaches price faster, at the price of overshoot at sharp turns. KAMA (Kaufman adaptive moving average) changes its own speed, fast when price moves cleanly in one direction and slow when it chops, and is slow to speed up again after a long range. The Hilbert oscillator cycle guide describes a different approach entirely: instead of smoothing less, it measures the dominant cycle in price and times turns from it, which is unstable when no clear cycle exists.
| Tool | How it cuts lag | What it costs you | Typical use |
|---|---|---|---|
| DEMA | Adds back the EMA's lag once | More noise than EMA | Trend filter or crossover |
| TEMA | Adds the lag back twice | Even more noise | Same, faster |
| Hull moving average | Weighted averages of half and full length | Overshoot at turns | Smooth trend line |
| KAMA | Speeds up when price trends, slows in ranges | Slow to re-speed after ranges | Adaptive filter |
| Hilbert oscillator | Measures the dominant cycle instead of smoothing | Unstable when no clear cycle | Cycle timing |
None of these tools removes the trade-off from the third section; each moves the point where it falls. So the comparison that means something is not which line looks fastest on a chart, but which one, at a plateau length on your market and bar size, leaves the largest average trade after costs with a whipsaw share you can live through.
A test you can run this week: take the crossover rule you already use, run it with EMA and with DEMA over the same band of lengths on the same data, with the same commission, slippage and next-bar fills. For each run write down three numbers: trades, trades that exited at a loss within three bars, and average trade after costs. If the DEMA column shows more trades and a smaller average trade, the lag it removed was paid for by noise on that market, and you have the figures to prove it.
Frequently asked questions
Does DEMA lag less than EMA?
Yes, at the same length. DEMA takes an EMA, estimates how far it trails price by comparing it with an EMA of that EMA, and adds the gap back, so the line sits closer to current price during a move. The reduced lag comes with more crosses in sideways markets and some overshoot at sharp turns.
What is the difference between DEMA and EMA?
Both average the same prices over the same length. EMA stops there; DEMA applies a correction, 2×EMA minus the EMA of the EMA, that pulls the line forward. In practice DEMA turns earlier at reversals and hugs price more tightly, while EMA turns later and gives fewer false signals in a range.
How do you set DEMA parameters?
The only setting that matters is the length. Start from the holding time you want and the round-trip cost you pay, test a band of lengths from about half to double your starting point, and keep a value in the middle of a flat region of results. A length whose neighbours give very different results is describing noise in that particular history.
Is the DEMA indicator useful?
It is useful when the earlier turns it gives pay for the extra false signals it also gives, after commission and slippage, on the market and bar size you trade. That is a test result, not a property of the indicator. Run the same crossover rule with EMA and DEMA at the same lengths, count whipsaw trades and compare the average trade after costs.
Is DEMA the same as an EMA of an EMA?
No. An EMA of an EMA is a line smoothed twice, and it lags more than a plain EMA. DEMA uses that doubly smoothed line only as a helper to measure lag, then subtracts it from twice the first EMA. The name refers to the 2× in the formula, not to smoothing twice.
References
- Bailey, D. H., Borwein, J., López de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458–471.
- Brock, W., Lakonishok, J., & LeBaron, B. (1992). Simple Technical Trading Rules and the Stochastic Properties of Stock Returns. The Journal of Finance, 47(5), 1731–1764.
- Pardo, R. (2008). The Evaluation and Optimization of Trading Strategies (2nd ed.). John Wiley & Sons.
- CME Group. E-mini Nasdaq-100 Futures Contract Specs. https://www.cmegroup.com/markets/equities/nasdaq/e-mini-nasdaq-100.contractSpecs.html

