Exponential Moving Average Strategy (EMA): Backtest and Evaluation
The exponential moving average strategy is one of the most commonly used among traders. But do you know what it is? And do you know if an exponential average strategy can be used profitably in the stock market?
Backtests indicate that exponential moving averages strategy do work: They can be useful for mean-reversion strategies if you use a short number of days in the moving average, and useful for long-term trend following if you use a high number of days in the moving average.
Also referred to as the exponentially weighted moving average, the exponential moving average (EMA) is a type of moving average indicator that places a greater weight and significance on the most recent data points. Thus, it follows the price more closely than the simple moving average.
Exponential moving average strategy backtest and best settings
Right off the bat, we backtest four different exponential moving average strategies. If you want to understand what an exponential moving average is, you can read more about that after our backtests. This backtest involves analyzing the average price of the asset over a given period, focusing on the importance of the average price in technical analysis.
What are we trying to find out?
We want to know if an exponential moving average crossover system can be used profitably in trading systems. Can you make money using exponential moving averages? In our process, we emphasize the use of the asset’s closing price for the day as a crucial element in calculating the EMA, which significantly impacts its responsiveness to price movements.
We do our backtest on the most traded instrument in the world: the S&P 500, analyzing the sum of closing prices in a given time period as part of the EMA formula. We test on SPDR S&P 500 Trust ETF which has the ticker code SPY.
Trading Rules – Exponential moving average
THIS SECTION IS FOR MEMBERS ONLY. _________________ Click Here To Get Access Click Here To Get Access To Trading RulesThe results from the two first backtests are summarized in these two tables:
Strategy 1
Period |
5 |
10 |
25 |
50 |
100 |
200 |
CAR |
7.41 |
6.83 |
5.51 |
3.55 |
2.8 |
1.6 |
MDD |
-30.54 |
-34.68 |
-37.13 |
-45.67 |
-50.71 |
-51.35 |
Strategy 2
Period |
5 |
10 |
25 |
50 |
100 |
200 |
CAR |
2.15 |
2.73 |
4.02 |
5.94 |
6.72 |
7.84 |
MDD |
-64.88 |
-52.42 |
-51.12 |
-33.11 |
-42.74 |
-25.94 |
What are the main takeaways from the two tables?
The first is that in the short run, it’s better to buy when the close crosses below a short-term moving average and sell when it closes above. This can be seen in table one: as the number of days in the exponential moving average increases, the CAGR (CAR) goes down. Such strategies that buy on weakness and sell on strength are called mean-reversion. The best strategy in table 1 is to use a 5-day moving average and that strategy yields a CAGR of 7.41%, which is pretty good while max drawdown is “only” 30.54%, much lower than for buy and hold. Please keep in mind that the results don’t include reinvested dividends.
The second takeaway is that the opposite strategy is more useful in the long run: The higher the number of days in the moving average the more profitable it is to buy when the close crosses above the moving average and sell when it closes below. This is called trend-following strategies. The longer the average is, the better. The 200-day moving average returns 7.84%, which is pretty decent. Worth noting is that the max drawdown is just half of buy and hold (26 vs 56%).
Let’s move on to backtest 3 and 4. The results are summarized in these two tables:
Strategy 3
Period |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.26 |
0.53 |
1 |
2.11 |
3.79 |
8.54 |
10 |
0.15 |
0.42 |
1.21 |
2.18 |
4.45 |
8.85 |
25 |
0.17 |
0.53 |
0.96 |
2.3 |
3.92 |
9.17 |
50 |
0.42 |
0.53 |
1.13 |
2.59 |
4.96 |
10.17 |
100 |
0.42 |
0.84 |
1.96 |
3.16 |
5.58 |
9.27 |
200 |
0.51 |
0.39 |
0.93 |
3.65 |
4.83 |
7.66 |
Strategy 4
Period |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.23 |
0.28 |
0.89 |
2.52 |
3.95 |
8.95 |
10 |
0.14 |
0.19 |
1.02 |
1.72 |
3.88 |
9.12 |
25 |
0.19 |
0.31 |
0.82 |
1.67 |
3.65 |
8.24 |
50 |
0.26 |
0.35 |
0.79 |
1.21 |
3.61 |
8.62 |
100 |
0.41 |
0.34 |
1.54 |
2.21 |
4.96 |
8.65 |
200 |
0.33 |
0.01 |
0.15 |
2.59 |
5.49 |
7.43 |
The entry into a trade is the same as in strategies 1 and 2, but we exit after N-days. Thus, this is not a crossover system. We already know that profitability increases the longer you are invested in stocks, and the tables show that. The best strategy is to buy when the close crosses below the 50-day moving average and sell after 200 days. This produces 10.17% per trade.
These four strategies are, of course, not the only way to trade moving averages. There are potentially unlimited methods and ways to use an exponential moving average, and only your imagination limits you. We have mentioned many other methods and techniques in our article called are moving averages good or bad.
The first is that in the short run, it’s better to buy when the close crosses below a short-term moving average and sell when it closes above. This can be seen in table one: as the number of days in the exponential moving average increases, the CAGR (CAR) goes down. Such strategies that buy on weakness and sell on strength are called mean-reversion. The best strategy in table 1 is to use a 5-day moving average and that strategy yields a CAGR of 7.41%, which is pretty good while max drawdown is “only” 30.54%, much lower than for buy and hold. Please keep in mind that the results don’t include reinvested dividends.
The second takeaway is that the opposite strategy is more useful in the long run: The higher the number of days in the moving average the more profitable it is to buy when the close crosses above the moving average and sell when it closes below. This is called trend-following strategies. The longer the average is, the better. The 200-day moving average returns 7.84%, which is pretty decent. Worth noting is that the max drawdown is just half of buy and hold (26 vs 56%).
Let’s move on to backtest 3 and 4. The results are summarized in these two tables:
The entry into a trade is the same as in strategies 1 and 2, but we exit after N-days. Thus, this is not a crossover system. We already know that profitability increases the longer you are invested in stocks, and the tables show that. The best strategy is to buy when the close crosses below the 50-day moving average and sell after 200 days. This produces 10.17% per trade.
These four strategies are, of course, not the only way to trade moving averages. There are potentially unlimited methods and ways to use an exponential moving average, and only your imagination limits you. We have mentioned many other methods and techniques in our article called are moving averages good or bad.
What is an exponential moving average (EMA)?
The exponential moving average, also referred to as the exponentially weighted moving average, is a type of moving average indicator that places a greater weight and significance on the most recent data points. It is similar to Simple Moving Average (SMA) in measuring trend direction over a period.
However, while the SMA simply calculates an average of price data, the EMA applies more weight to data that is more current. As a result of this method of calculating the average, the EMA will follow prices more closely than a corresponding SMA.
As with all other moving average indicators, the EMA aims to use past prices to establish the direction the price of an asset is moving. Therefore, exponential moving averages are lag indicators. They are not predictive of future prices; they simply highlight the trend that is being followed by the stock price.
For your convenience, we made a screenshot in Amibroker to show you the difference between a simple and an exponential moving average:
Exponential moving average(blue line) vs a simple moving average.
The blue line is the exponential moving average and it clearly deviates toward the right end. That is because it puts more emphasis on the last prices and is not equal-weighted as the simple moving average is. This characteristic makes EMAs particularly useful in analyzing trends across various financial markets, including stocks, forex, and commodities, where they help traders forecast price direction with greater accuracy.
How to calculate EMA
The EMA calculation is a bit more complex than that of the SMA. It is designed to be more responsive to current market conditions by giving greater weight to recent price movements. This approach ensures that the newest price data has the most impact on the moving average, significantly reducing the lag time in trend identification and minimizing false signals. Conversely, the oldest price data has the least impact. The calculation also incorporates the previous value of the EMA, meaning it includes all the price data within its current value, emphasizing the importance of recent price movements in its formulation.
The formula is given as:
EMA = (K x (C – P)) + P
Where:
C = Current Price
P = Previous periods EMA (A SMA is used for the first period’s calculations)
K = Exponential smoothing constant
The smoothing constant, K, is critical as it applies the appropriate weight to the most recent price, enhancing the EMA’s responsiveness to changes in market conditions. It uses the number of periods specified in the moving average, calculated as follows:
K – 2/(n + 1))
Where:
N = the selected period
Why use an EMA?
As with other moving average types, the EMA smooths the price data, reducing the noise, so that traders can make a better sense of what the price is doing. It can help a trader to spot the direction of the trend, as well as identify when the trend is changing direction. But as the chart above shows, the exponential moving average reacts more strongly to the latest records. Thus, you can only find out what is best via backtests.
How to use an EMA
About any trading platform out there has a built-in EMA indicator. So, all a trader needs to do is just attach the indicator to the chart and adjust the settings to what they want. We have given you some ideas in this article with our four backtests above, but there are plenty of other ways to use an exponential moving average. Combining EMA with other technical indicators like the Moving Average Convergence Divergence (MACD) and the Relative Strength Index (RSI) can significantly enhance trading strategies.
But as a rule of thumb, mean reversion works best in the stock market in the short term, while trend-following works best in the long run. Utilizing the Relative Strength Index (RSI) alongside the EMA is particularly effective for identifying optimal trading opportunities.
How can you use an EMA?
We believe it’s most useful as a crossover strategy, as we showed in the four backtests above.
However, you can use the EMA to determine the trend direction so that you trade in that direction. Thus, when the EMA is rising, you may want to look for only buying opportunities. On the other hand, when the EMA is declining, you may have to look for short-selling strategies and opportunities.
Since moving averages can also indicate support and resistance areas. The EMA can serve as a support in an uptrend and as a resistance in a downtrend. This reinforces the strategy of buying when the price is around a rising EMA and selling when the price is around a falling EMA.
But as always in trading, creatively pays off. We use moving averages in our own trading but only as part of other parameters.
Drawbacks with an EMA
Although the EMA is faster than the SMA, it still lags and thus, cannot be used to identify a trade at the exact price turning points. There would always be a delay at the entry and exit points. If you reduce the period to make it move closer to the price, it gives more false signals.
More articles about moving averages strategies that include backtests
Moving averages are popular trading tools and for good reason. They can be used on their own but also as one of several parameters in a trading strategy.
Moving averages were probably more useful earlier than they are now. They have been around for a long time and were used when the first computers were used to develop trading strategies in the 1970s, for example by Ed Seykota. We suspect the most low-hanging fruit is already “arbed” away.
This is our list of all relevant articles to moving averages:
For your convenience, we have covered all moving averages with both detailed descriptions and backtests.
Here you can find all our Moving average strategies.
FAQ exponential moving average (EMA)
We end the article with some frequently asked questions:
Q: What is an exponential moving average (EMA)?
A: An exponential moving average (EMA) is a type of moving average that places a greater weight on recent prices in an effort to make it more responsive to new information.
Q: How is an EMA different from a simple moving average (SMA)?
A: An EMA gives more weight to recent prices than a SMA, which gives equal weight to all prices in the time period. This makes an EMA more sensitive to recent price changes than a SMA.
Q: What is the formula for calculating an EMA?
A: The formula for calculating an EMA is: EMA = (Price x (2/(Time Period + 1))) + (EMA of Prior Period x (1 – (2/(Time Period + 1))))
Q: What is the time period used for calculating an EMA?
A: The time period used for calculating an EMA is typically set by the trader and can range from a few days to several months.
Q: How is an EMA used?
A: An EMA is often used by traders to identify trends or to confirm the strength of a trend. It is also used to identify support and resistance levels.
Q: Are there any drawbacks to using an EMA?
A: One potential drawback to using an EMA is that it can be too responsive to recent price changes and may lead to false signals. It is important to use other indicators in combination with an EMA to confirm signals.
Q: What is a good exponential moving average?
A: There is no good or bad exponential moving average. If you backtest yoiu’ll find out what is the best moving average for your asset class.
Q: Which exponential moving average is best for swing trading?
A: See answer above. Only a backtest can give you an answer.
Q: Is EMA a good indicator?
A: Yes, but our experience indicates it’s best as one of more parameters. For example, a simple moving average can be used as a trend filter. Please check out our pullback trading strategy.
Q: Do most traders use EMA or SMA?
A: We believe most traders use SMA. However, we believe SMA and EMA are not that different.
Exponential moving average – takeaways and conclusions
We would say that the main conclusion from this article is that exponential moving average strategies work best for either a low or high number of days in the moving average. Mean reversion is best for a short number of days, and trend following for a high number of days.
FAQ:
How does the EMA differ from the simple moving average (SMA)?
The exponential moving average, or EMA, is a type of moving average indicator that gives greater weight to recent data points, making it more responsive to current market conditions. Unlike the SMA, which gives equal weight to all prices in a time period, the EMA places more weight on recent prices, making it more sensitive to changes in the market.
What are mean-reversion and trend-following strategies in EMA trading?
Mean-reversion involves buying on weakness and selling on strength with a short-term EMA. Trend-following, on the other hand, focuses on buying when prices cross above a long-term EMA and selling when they cross below. The EMA is calculated using the formula: EMA = (K x (C – P)) + P, where C is the current price, P is the previous period’s EMA, and K is the exponential smoothing constant.
Why use an EMA in trading, and how can it be applied?
While the EMA is faster than the SMA, it still lags and may lead to false signals. The EMA helps smooth price data, reducing noise and aiding in trend identification. Traders can use it for crossover strategies or to determine the direction of the trend for buying or selling opportunities.