DEMA
DEMA is not a double average — it is an average plus an estimate of its own lag, added back. That extrapolation is what makes it lead, and it is also why the line can sit at a price the market never traded, which no true moving average can do. MetaTrader 5 ships it as iDEMA, and the length you set is half the history it needs.
- Period set
- 14
- Bars needed
- 26
- Buffers plotted
- 1 of 3
Ilustrativo — dados sintéticos, não uma cotação em tempo real.
What DEMA tells you
Every moving average is late, and the lateness is not random — it is roughly proportional to the average's own distance behind price. DEMA exploits that. It takes an EMA, then takes an EMA of that EMA, and the gap between the two is a serviceable estimate of how far behind the first one is running. Doubling the first and subtracting the second adds that estimate back, so the line arrives at a new level far sooner. What you are looking at is therefore not an average of anything: it is an average with a correction bolted on, and corrections can be wrong in the direction of too much.
- It reaches a new level in about a third of the bars a plain EMA needs
- It can print values price never traded at — a real average cannot
- There is no adaptation: the smoothing is fixed, only the lag is cancelled
- 1 EMA of price, then an EMA of that EMA
- 2 Their difference estimates how far the first EMA is lagging
- 3 DEMA = 2 x EMA − EMA(EMA) — the same average with that lag added back
Mostrar a fórmula e detalhes de cálculo
DEMA is one line of arithmetic:
DEMA = 2 × EMA(price) − EMA(EMA(price))
The trick is in the second term. An EMA lags price; an EMA of that EMA lags it again, by roughly the same amount. So the gap between the two is a usable estimate of how far behind the first one is running — and doubling the first while subtracting the second adds that estimate back on top.
That makes it an extrapolation, not an average. The distinction has a consequence you can see. A moving average is a weighted sum of the prices in its window whose weights add to one, so the result always lands somewhere between the lowest and highest of them. DEMA has no such guarantee:
- On a step from 100 to 110, the line peaks at 111.17 — above the highest price that ever existed in the series
- On a random walk with period 14, it sits outside the last fourteen bars’ high-low range on 2.1% of bars
- The same test run against the plain EMA it is built from: 0.0%
The upside is measured just as plainly. On that same step, a plain EMA needs 20 bars to reach 95% of the new level. DEMA needs 6.
The period is half the history. The second EMA cannot start until the first has produced values, so MT5 sets PLOT_DRAW_BEGIN to 2 × period − 2 and calculates nothing before then. A DEMA(14) needs 26 bars; a DEMA(50) needs 98. Nothing errors — the left of the chart is simply empty.
Earlier is not smoother. The usual reason to reach for this indicator is that an EMA feels late, and the usual mistake is to also expect it to be cleaner. It is the same EMA with a correction added, and the correction amplifies whatever the EMA was doing, noise included. In a trend that is exactly what you want. In a range the correction goes on supplying lead to a move that never arrives, and the crossings multiply — which is what the template’s stop distances, and the trend filter suggested above, exist to survive.
Sinais
Os sinais distintos e testáveis que DEMA oferece — e o regime adequado para cada um.
Price Against the Line
Pronto no BuilderDEMA Against Its Own EMA
Pronto no BuilderOvershoot Past the Range
Lógica avançadaImplementação no MT5
O que o MetaTrader 5 realmente calcula e desenha — a referência para cada regra desta página.
Buffers
| Índice | Buffer | Desenhado no MT5 como | O que contém |
|---|---|---|---|
| 0 | MAIN_LINE | DEMA | The line, and the only series MT5 plots. The indicator declares three buffers, but the other two hold the intermediate EMA and the EMA of that EMA and are marked INDICATOR_CALCULATIONS — working storage rather than output. The Builder reads index 0. |
Notas da plataforma
Funciona melhor / use com cuidado
Nenhum indicador tem vantagem universal. Veja onde DEMA ajuda — e onde ele engana.
Funciona melhor
- Trends where being a few bars earlier is worth paying for
- As the fast side of a pair, where a slower line supplies the confirmation
- Timeframes where an EMA of the same length feels a beat behind the move
- Replacing an EMA that has been shortened repeatedly to chase responsiveness — this is the principled version of that
Use com cuidado
- Ranges: the correction keeps adding lead to a move that is not going anywhere, so crossings multiply
- Treating the line as a level — it regularly sits where price has never been
- Short histories: nothing is drawn until twice the period minus two bars exist
- Assuming it is smoother than an EMA. It is not smoother; it is earlier, and earlier is noisier
Criar uma estratégia DEMA
Conecte o sinal às regras de entrada e saída, depois exporte um EA MT5 compilável — sem código.
- Two DEMA nodes on Close — one at 14, one at 28
- Fast crosses above slow → Close the short, then Open Buy · SL 70 / TP 210
- Fast crosses below slow → Close the long, then Open Sell
- Both read the last closed bar, so a cross is a settled fact
- The close nodes are placed ahead of the entries, and the order matters
Combinar DEMA com outros indicadores
Um indicador raramente funciona sozinho. Essas combinações cobrem os pontos cegos do DEMA.
DEMA + Moving Average
- A plain EMA at 14
- DEMA at 14
- Compare
No single-flow template pairs them. Start from DEMA 14/28 Lead Cross, add a Moving Average node set to EMA 14, and put it into a Compare against the fast DEMA.
Abrir o Builder →DEMA + ADX
- ADX above 25
- Fast DEMA crosses above slow
- Buy
No single-flow template combines them. Add an ADX node with a Compare at 25 to DEMA 14/28 Lead Cross and join it to the Cross with an And gate.
Abrir o Builder →DEMA + FrAMA
- FrAMA above a fixed average
- Fast DEMA crosses above slow
- Buy
No single-flow template pairs them. Add a FrAMA node and a Moving Average node into a Compare, then join that to the DEMA Cross with an And gate.
Abrir o Builder →DEMA + TEMA
- TEMA at 14
- Fast DEMA crosses above slow
- Buy
No single-flow template pairs them. Add a TEMA node at 14 on Close to DEMA 14/28 Lead Cross and put it into a Compare against the fast DEMA — or start from EMA Cross Entry x TEMA Early Exit and add DEMA there instead.
Abrir o Builder →Parâmetros
Valores iniciais para validar no seu próprio par e timeframe — não são configurações garantidas.
| Parâmetro | Padrão | Faixa de teste sugerida | O que faz |
|---|---|---|---|
| Period | 14 | 1–999 | The EMA length used twice — once on price and once on the result. It behaves like an ordinary length in that longer is slower, but the history it consumes is not what you set: MT5 draws nothing until 2 × period − 2 bars exist, because the second EMA cannot start until the first one has. A DEMA(50) needs 98 bars. |
| Applied price | Close | Close / Open / High / Low / Median / Typical / Weighted | Which series the whole calculation runs on. Unlike FrAMA, where the setting barely matters, here it is a real control: both EMAs and therefore the correction are computed from whatever you choose. |
| Shift | 0 | 0–100 | Which bar to read. The template sets 1 so a cross is decided on a closed bar. This is not iDEMA's own ma_shift, which slides the drawn line sideways — the Builder pins that to 0 and exposes only the bar offset. |
| Timeframe | Current | Current / M1–MN1 | Which timeframe's bars the line is built from. Set above the chart and it becomes a faster-than-usual read of a slower trend, which is a reasonable way to use the lead without trading every crossing on the chart's own bars. |
Predefinições iniciais
Exemplos de mercado
Onde DEMA funciona, onde falha e como um filtro muda o resultado.
In before the average
A move begins and the fast line separates from the slow one several bars before the equivalent EMA pair would have crossed. The position is open for the part of the move that a slower crossover spends waiting.
The lead that led nowhere
A sideways stretch produces a cross, then the opposite cross four bars later, then a third. The correction term kept adding lead to a move that was never there — the failure mode the trend filter exists for.
Same stretch, strength required
The identical range with a trend-strength condition attached to the cross. The lines still cross and no order is sent, because the flow was asked for something the crossover alone cannot say.
Indicadores relacionados
FAQ
- Is DEMA built into MetaTrader 5?
- Yes. iDEMA is a standard MQL5 function taking a symbol, a timeframe, the period, an ma_shift and an applied price, and the terminal also ships a DEMA custom indicator under Indicators\Examples. The Builder calls the built-in, so a generated EA needs no extra files on the terminal that runs it.
- Is it just an EMA of an EMA?
- No — that would be slower, not faster. It uses an EMA of an EMA, but subtracts it: DEMA = 2 × EMA − EMA(EMA). The second term lags the first in the same way the first lags price, so their difference estimates that lag, and adding it back moves the line forward rather than smoothing it further.
- Why does it sometimes go above the highest price on the chart?
- Because it is an extrapolation, not an average. An average of a window always lands inside that window's range; the doubling and subtraction here remove that guarantee. Measured on a step from 100 to 110 the line peaks at 111.17, and on a random walk it sits outside the last fourteen bars' range on 2.1% of bars against 0.0% for a plain EMA. It is expected behaviour, and it is the reason not to read the line as a price level.
- How many bars does it need before it draws?
- 2 × period − 2. The EMA of the EMA cannot start until the first EMA has produced values, so a period of 14 needs 26 bars and a period of 50 needs 98. MT5 returns without calculating while the history is shorter, so the left of the chart is simply empty rather than wrong.
- How is it different from an adaptive average like FrAMA?
- They attack the same problem from opposite ends. An adaptive average varies how much smoothing to apply, measuring the market and easing off when it is directional. DEMA never changes its smoothing — it leaves the EMA exactly as it was and subtracts an estimate of the lag instead. The visible consequence is in ranges: an adaptive line goes flat and stops signalling, while DEMA keeps leading and keeps crossing.
- Can I build a DEMA EA without coding?
- Yes. The DEMA 14/28 Lead Cross template uses two DEMA nodes on Close and trades the crossings between them, closing the opposite side before it enters. The two periods, the applied price, the shift, the stop distances, the lot and the spread limit are all EA inputs.
- How should I validate settings before going live?
- Backtest on quality tick data, then demo, and read the trade list rather than only the curve. Two things are specific to this indicator. Make sure the test spans a range as well as a trend — the lead is an advantage in one and a liability in the other, and a test containing only trends measures half the behaviour. And resist shortening the period to get more lead: the correction already supplies it, and a shorter period compounds the overshoot rather than improving the timing.
Artigos relacionados
Glossary