Double Exponential Moving Average

The Double Exponential Moving Average (DEMA) of Patrick Mulloy (1994) reduces the lag of the EMA by subtracting the EMA of the EMA, which lags twice as much, from twice the EMA.

The formula for the Double Exponential Moving Average starts from the EMA of the closing price over n periods and the EMA of that EMA over the same n periods:

\[\text{EMA}_{1} = \text{EMA}(\text{Close}, n)\] \[\text{EMA}_{2} = \text{EMA}(\text{EMA}_{1}, n)\]

Twice the first EMA minus the second removes most of the lag of the first:

\[\text{DEMA} = 2 \cdot \text{EMA}_{1} - \text{EMA}_{2}\]

Where EMA(x, n) is the exponential moving average of x over n periods, with \(\alpha = 2 / (n + 1)\). The DEMA is not a double smoothing: it stays close to the price and turns earlier than the EMA, but it overshoots the price after a sharp move.

A moving average smooths the price by averaging it over the last n periods, so that the trend shows through the noise of single periods. It is the oldest and most widely used trend indicator: the direction of the average shows the direction of the trend, the price above (below) it an uptrend (downtrend), and other indicators, from the MACD to the Bollinger Bands, are built on it. Every moving average trades smoothness against lag: the more periods it averages, the smoother it is and the later it turns after the price. The averages differ in how they weight the prices within the window and whether they adapt their speed to the market, each a different answer to that trade-off.

Also known as: DEMA.

In the Finance Toolkit this is get_moving_average with method="double_exponential", the same function as Moving Average.

Example · ^GSPC · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_moving_average:

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["^GSPC"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.technicals.get_moving_average(method="double_exponential", window=50)

Which returns:

References

  • Paper Mulloy, P.G. (1994). “Smoothing Data with Faster Moving Averages.” Technical Analysis of Stocks & Commodities, 12(1).
  • Library Referenced against TA-Lib’s DEMA (Double Exponential Moving Average)
Share