Double Exponential Moving Average – Trading Strategy Backtest (Does it work?)
Last Updated on January 10, 2023
Double exponential moving average strategy backtest
Traders are always looking for an edge in the market. While some employ the use of chart patterns, others simply trade based on indicators. An example of such an indicator is the double exponential moving average (DEMA). But do you know what it is? And is it possible to develop profitable double exponential moving average strategies?
Yes, double exponential moving average strategies do work. Our backtests show that a double exponential moving average strategy can be used profitably for both mean-reversion and trend-following strategies on stocks.
The double exponential moving average (DEMA) is not as commonly used as the other types of moving averages. The DEMA gives more weight to the most recent price. This weighting results in a more reactive moving average, which is useful to short-term traders to profit from the market.
Double exponential moving average strategy backtest and best settings
Before we go on to explain what a double exponential moving average is and how you can calculate it, we go straight to the essence of what this website is all about: quantified backtests.
Our hypothesis is simple:
Does a double exponential moving average strategy work? Can you make money by using double exponential moving averages strategies?
We look at the most traded instrument in the world: the S&P 500. We test on SPDR S&P 500 Trust ETF which has the ticker code SPY.
All in all, we do four different backtests:
- Strategy 1: When the close of SPY crosses BELOW the N-day moving average, we buy SPY at the close. We sell when SPY’s closes ABOVE the same average. We use CAGR as the performance metric.
- Strategy 2: Opposite, when the close of SPY crosses ABOVE the N-day moving average, we buy SPY at the close. We sell when SPY’s closes BELOW the same average. We use CAGR as the performance metric.
- Strategy 3: When the close of SPY crosses BELOW the N-day moving average, we sell after N-days. We use average gain per trade in percent to evaluate performance, not CAGR.
- Strategy 4: When the close of SPY crosses ABOVE the N-day moving average, we sell after N-days. We use average gain per trade in percent to evaluate performance, not CAGR.
The results of the first two backtests look like this:
Strategy 1
Period |
5 |
10 |
25 |
50 |
100 |
200 |
CAR |
7.42 |
10.48 |
6.57 |
6.9 |
6.81 |
5 |
MDD |
-22.22 |
-26.98 |
-34.4 |
-36.35 |
-37.8 |
-51.23 |
Strategy 2
Period |
5 |
10 |
25 |
50 |
100 |
200 |
CAR |
2.16 |
-0.67 |
2.98 |
2.65 |
2.74 |
4.51 |
MDD |
-66.56 |
-74.2 |
-57.71 |
-61.13 |
-54.38 |
-41.34 |
The results from the backtests are pretty revealing: in the short run, the stock market shows tendencies to mean-reversion. In the long run, it is better to use trend-following strategies, although the latter has one od the weakest returns for this strategy among all moving averages (see list further down in the article).
Why do we reach that conclusion?
Because if we use a double exponential moving average, the best strategy is to buy when stocks drop below the average and sell when it turns around and close above the moving average (buy on weakness and sell on strength). This can clearly be seen in the first test above for the 5-day moving average. The 5-day moving average returns a CAGR of 7.42%, which is almost as good as buy and hold even though the time spent in the market is substantially lower. The max. drawdown is also reasonably low at 22.22%.
When we buy on strength and sell on weakness, in the second test in the table above, the best strategy is to use many days in the average. The longer the average is, the better. The 200-day moving average returns 4.51%, which is pretty decent, but not as good as many of the other types of moving averages.
The results from backtests 3 and 4 look like this (the results are not CAGR, but average gains per trade):
Strategy 3
Period |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.12 |
0.5 |
1.13 |
2.02 |
4.5 |
8.77 |
10 |
0.22 |
0.39 |
1.03 |
2.19 |
4.39 |
9.17 |
25 |
0.18 |
0.44 |
0.88 |
2.05 |
4.04 |
9 |
50 |
0.18 |
0.37 |
0.73 |
2 |
4.73 |
8.98 |
100 |
0.09 |
-0.01 |
0.41 |
1.52 |
3.53 |
9.76 |
200 |
0.34 |
0.58 |
0.87 |
1.77 |
5.11 |
8.31 |
Strategy 4
Period |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.21 |
0.26 |
0.86 |
2.28 |
4.52 |
9.05 |
10 |
0.1 |
0.11 |
0.82 |
1.8 |
3.97 |
8.55 |
25 |
0.13 |
0.29 |
1.13 |
2.39 |
4.11 |
8.97 |
50 |
0.11 |
0.13 |
0.35 |
1.64 |
3.63 |
8.58 |
100 |
-0.06 |
-0.02 |
0.32 |
1.1 |
3.57 |
9.15 |
200 |
0.04 |
0.08 |
0.74 |
1.59 |
3.83 |
9.34 |
As expected, the longer you are in the stock market, the better returns you get. This is because of the tailwind in the form of inflation and productivity gains. We can clearly see that when we increase the length of N-bar exit.
However, be aware that this is just one method of testing a moving average. There are basically unlimited ways you can use a moving average and your imagination is probably the most restricting factor!
What is a double exponential moving average (DEMA)?
The double exponential moving average (or DEMA, for short) is an overall improvement over the exponential moving average (EMA) because it responds very quickly to recent prices. The name double is derived from how it is calculated because it uses two EMA (EMA of an EMA) to develop its value. The DEMA was developed by Patrick Mulloy in the mid-1990s.
The indicator tends to eliminate most of the lags seen in a traditional moving average and can be very helpful in the analysis of short-term trends.
Take a look at the chart of gold above. Using the chart as an example, you can see two moving averages plotted as lines. The 20-period simple moving average is the blue line, while the orange line represents the 20-period double exponential moving average. You can clearly see that while both of the averages have the same period, they react to price differently. The double exponential moving average (orange line) tends to stay closer to the price compared to the simple moving average (blue line). The DEMA gives an early signal, unlike the lagging simple moving average.
The DEMA will normally take the direction the market is expected to move in the future. A rising DEMA is interpreted as a probable rise in price, while a falling DEMA indicates a probable fall in price.
When the price of an asset is above the DEMA, a rally is likely to occur, and if it is below, the price is likely to further decline. In an uptrend, a break of the DEMA downwards may signify the end of the uptrend. Similarly, in a downtrend, a break of the line to the upside signifies a potential reversal in the market.
A daily chart of GBPUSD showing the long-term trend, as indicated by the 200-period double exponential moving average.
How to calculate a double exponential moving average
The double exponential moving average comprises a basic exponential moving average and a smoothed moving average. This combination reduces the inherent lag seen in the simple moving average.
The formula and calculation for the double exponential moving average is as follows:
DEMA = (2 X EMA_{n} 1) – (EMA of EMA_{n} 1)
Where:
EMA 1 = initial EMA,
n = lookback period.
A breakdown of the calculation above is given below:
- First, the lookback period is chosen. This could be 10 period, 20 period, or 50 period.
- Next, the EMA for your chosen period is calculated. This is given as EMA_{n}.
- Next, another EMA with the same lookback period as the EMA_{n }is applied. This new EMA will now become the smoothed EMA.
- Then, the EMA_{n }is multiplied by 2 and subtracted from the smoothed EMA.
Why use a double exponential moving average?
If you are a day trader or swing trader, you may find the double exponential moving average more useful than a traditional moving average. This is because the DEMA responds more quickly to price action than the simple moving average.
The double exponential moving average is typically used to identify an uptrend or downtrend in the market, and also to determine the strength. Generally, traders will monitor the market for a price move above or below the DEMA. Additionally, multiple DEMA with different lookback periods can be added to your chart when you employ the moving average crossover strategy.
Also, the DEMA can serve as dynamic support and resistance. It can help a trader to spot areas of value on the chart. These are areas on the chart where a trend is most likely to pause or even change.
How to use a double exponential moving average
Some trading platforms have built-in DEMA. So, all you need to do is to search it in the indicator tab and add it to the chart. You may adjust the settings of the indicator to suit your needs. However, if your trading platform does not have built-in DEMA, you can code it yourself or have someone do it for you.
To have the DEMA follow price more closely and show individual price swings, a low lookback period is ideal, say 5, or even 10. To have it show a longer-term trend, a high lookback period is advised, say 100 or 200. But, you would be better off with a simple moving average for longer-term trends.
How can you use a double exponential moving average?
You can use the DEMA to trade in many ways. Some of the ways you can use it are discussed below.
Identify trend
Just like the simple moving average, the double exponential moving average can also be used to identify the market direction whether long-term or short-term. For a long-term trend, a 200-period is usually used. While settings like the 10, 20, and 50 periods are used to identify swing points in the market. You can use the indicator on any timeframe, but if you are a short-term trader, you may want to stick to lower timeframes.
You can see from the above chart of EURUSD that the price respected the 100-period DEMA. It acted as a resistance zone seeing that each time price reaches the line, it reverses. A similar situation is shown below.
Dema Crossover Strategy
The DEMA crossover strategy simply uses two DEMA on the price chart. One of the DEMA is plotted using a low lookback period while the other is plotted using a high lookback period, say a 20-period DEMA and a 50-period DEMA.
Let’s see how this works on a real chart.
The above is a daily chart of EURUSD. Two DEMA were plotted using the 20-period (green line) as the fast, and the 50-period (orange line) as the slow DEMA. You may adjust the settings according to your trading style. Some commonly used periods are the 5/10 DEMA, 9/18, 10/20, and 50/200 DEMA.
A buy signal is given when the fast DEMA (green line) crosses over the slow DEMA (orange line). A sell signal is provided when the fast DEMA crosses below the slow DEMA line.
This strategy works well in a market with a strong trend. Using this in ranging market conditions might subject you to false signals.
Buying on support and selling on resistance
You can buy and sell support and resistance on the DEMA. See the chart below.
From the above chart, you can see that price tested the DEMA multiple times. This makes it act as either support or resistance. For example, you could have bought at points (1) and (4) or sold at (2) and (3). Even though the price ranged at point (1), you could clearly see that price moved up eventually.
Trading with the DEMA might be profitable, or not, depending on your approach. Using the DEMA with other indicators may increase the accuracy of your trading decisions. You should note that there is no magic formula for trading. The most important thing is to pick a strategy or develop a trading system and backtest it on a demo account and master it. This is to ensure you have enough confidence in your system before jumping into the market with real capital.
Drawbacks with a double exponential moving average
The double exponential moving average can provide less or no insight during a period when the market is ranging. At this period, the indicator will generally give you false signals, as it will frequently move up and down, in a snake-like motion, with the price.
The strength of the DEMA is in its ability to follow the price more closely and reduce lag. But this can also be its weakness in unfavorable certain conditions.
Of course, the key benefit of a reduced lag is that it makes you exit a trade quicker – reducing losses. But reduced lag can also make you over-trade by giving you way too many signals. The DEMA might make you sell you when the market is making a minor pullback, leading you to miss out on a much better move if the trend persists.
As with most technical indicators, the double exponential moving average is much more useful when combined with other indicators or other forms of market analysis, such as fundamental analysis and price action analysis.
Relevant articles about moving averages strategies and backtests
Moving averages have been around in the trading markets for a long time. Most likely, moving average strategies were the start of the systematic and automated trading strategies developed in the 1970s, for example by Ed Seykota. We believe it’s safe to assume moving averages were a much better trading indicator before the 1990s due to the rise of the personal computer. The most low-hanging fruit has been “arbed away”.
That said, our backtests clearly show that you can develop profitable trading strategies based on moving averages but mainly based on short-term mean-reversion and longer trend-following. Furthermore, there exist many different moving averages and you can use a moving average differently/creatively, or you can combine moving averages with other parameters.
For your convenience, we have covered all moving averages with detailed descriptions and backtests. This is our list:
- Moving average trading strategies
- Exponential moving average (backtest strategy)
- Hull moving average (backtest strategy)
- Linear-weighted moving average (backtest strategy)
- Adaptive moving average (backtest strategy)
- Smoothed moving average (backtest strategy)
- Variable moving average (backtest strategy)
- Weighted moving average (backtest strategy)
- Zero lag exponential moving average (backtest strategy)
- Volume weighted moving average (backtest strategy)
- Triple exponential moving average TEMA (backtest strategy)
- Variable Index Dynamic Average (backtest strategy)
- Triangular moving average (backtest strategy)
- Guppy multiple moving average (backtest strategy)
- McGinley Dynamic (backtest strategy)
- Geometric moving average GMA (backtest strategy)
- Fractal adaptive moving average FRAMA (backtest strategy)
- Fibonacci moving averages (backtest strategy)
- Moving average slope (backtest strategy)
We have also published relevant trading moving average strategies:
- The 200-day moving average strategy
- Trend-following system/strategy in gold (12-month moving average)
- Trend following strategies Treasuries
- Is Meb Faber’s momentum/trend-following strategy in gold, stocks, and bonds still working?
- Trend following strategies and systems explained (including strategies)
- Does trend following work? Why does it work?
- A simple trend-following system/strategy on the S&P 500 (By Meb Faber and Paul Tudor Jones)
- Conclusions about trend-following the S&P 500
- Why arithmetic and geometric averages differ in trading and investing
FAQ Double exponential moving average
Let’s end the article with a few frequently asked questions:
What is a double exponential moving average (DEMA) strategy?
A DEMA strategy is a trend-following trading strategy that uses two exponential moving averages (EMAs) to identify buy and sell signals in the market, normally by a crossover system. The two EMAs used in this strategy are typical of different lengths and are used to identify changes in momentum.
You can, of course, find any combination that works by backtesting.
How does a DEMA strategy work?
A DEMA strategy works by combining two EMAs of different lengths on a chart. When the shorter-term EMA crosses above the longer-term EMA, it signals a buy signal.
Conversely, when the shorter-term EMA crosses below the longer-term EMA, it signals a sell signal.
What time frames are best suited for a DEMA strategy?
A DEMA strategy can be applied to most time frames, though it is most commonly used in the 1-hour, 4-hour, and daily time frames.
What are the benefits of using a DEMA strategy?
The main benefit of using a DEMA strategy is that it presumably helps traders identify changes in momentum more quickly and accurately than using a single EMA. Additionally, it can help traders filter out false signals that would otherwise be generated by using only a single EMA.
However, as we always write on this blog, is that you must backtest yourself to find the best trading systems.
What are the risks associated with a DEMA strategy?
As with any trading strategy, there are risks associated with a DEMA strategy. The primary risk is that the market could move against the trader and generate losses. Additionally, a DEMA strategy may not be able to identify all changes in momentum, leading to missed trading opportunities.
All moving averages have plenty of whipsaws!
Does the double exponential moving average work?
At the end of the day, all traders are most interested in making money. How they do it is of minor importance. Our backtests reveal that the double exponential moving average works pretty well on stocks, although it’s not the best moving average.
Double exponential moving average – takeaways
Our takeaway from the backtests is that a double exponential moving average (DEMA) works pretty well if you buy on weakness (a close below the moving average) when you use a short number of days. Opposite, it’s best to buy on strength (a close above the moving average) when you use a longer moving average.