Simple Moving Average – Trading Strategy Backtest (Does It Work?)
Last Updated on April 18, 2023
Simple moving average strategy backtests
Moving averages are one of the most commonly used indicators in technical analysis, and the simple moving average is the easiest one to construct. Do you know what it is? Can you make profitable simple moving average strategies in the markets?
Backtests indicate that you can use simple moving averages for short-term mean reversion and long-term trend-following. Additonally, you can use moving averages as a second parameter in a trading strategy.
A simple moving average (SMA) is a basic average of the price of an asset over a specified period calculated continuously for any new price data that forms in the time series. Since the price data keeps changing for each session and the average is calculated for each new data, the average changes constantly, which is why it is called a moving average.
Simple moving average strategy backtest and best settings
This website is all about quantified strategies, and we go straight to our backtests: what is the best use of a simple moving average? All in all, we test four different moving average crossover systems to find the best simple moving average strategy.
We backtest the following four different
- 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 backtests can be summarized in the following four tables – one for each system:
Strategy 1
MA Days |
5 |
10 |
25 |
50 |
100 |
200 |
CAR |
8.34 |
7.53 |
5.72 |
5.19 |
3.47 |
1.55 |
MDD |
-32.61 |
-38.01 |
-39.89 |
-39.82 |
-50.96 |
-52.18 |
Strategy 2
MA Days |
5 |
10 |
25 |
50 |
100 |
200 |
CAR |
1.27 |
2.07 |
3.8 |
4.29 |
5.98 |
7.89 |
MDD |
-66.05 |
-56.27 |
-48.42 |
-41.68 |
-50.82 |
-28 |
What conclusions can we draw from these two tables? The first thing that is quite obvious is that the stock market shows tendencies toward mean-reversion in the short run. This we can see in table one where it’s clearly much more profitable to buy when the close crosses below a short-term moving average than compared when it crosses above. The 5-day moving average returns a CAGR of 8.34% (which is pretty good). The buy and hold CAGR is 9%.
However, as the moving average gets longer, it turns upside down: then it’s getting more and more profitable to buy when the close crosses above the simple moving average. This means that trend-following strategies work best in the long term. The longer the average is, the better! The 200-day moving average returns 7.89%. We would say this is pretty good because the max drawdown is just half compared to buy and hold (28 vs 56%).
The last two backtests, 3 and 4, returned the following results:
Strategy 3
MA \ Bars |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.28 |
0.39 |
1.08 |
2.11 |
4 |
8.62 |
10 |
0.28 |
0.55 |
1.21 |
2.49 |
4.48 |
8.87 |
25 |
0.25 |
0.57 |
1.02 |
2.19 |
4.02 |
8.23 |
50 |
0.3 |
0.62 |
1.16 |
2.24 |
5.7 |
9.64 |
100 |
0.59 |
1.2 |
1.8 |
3.37 |
5.49 |
9.07 |
200 |
0.29 |
0.38 |
1.07 |
3.24 |
6.61 |
8.06 |
Strategy 4
MA \ Bars |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.22 |
0.23 |
0.86 |
2.26 |
3.75 |
8.92 |
10 |
0.23 |
0.44 |
0.92 |
1.96 |
4.09 |
9.3 |
25 |
0.26 |
0.37 |
1.01 |
1.42 |
4.01 |
7.62 |
50 |
0.06 |
0.15 |
0.46 |
1.35 |
4.36 |
9.14 |
100 |
0.3 |
0.43 |
1.36 |
2.47 |
5.35 |
7.3 |
200 |
0.24 |
-0.22 |
0.38 |
2.81 |
5.87 |
10.93 |
Tables 3 and 4 confirm what we found out in tables 1 and 2: longer you stay invested in stocks, the better the returns. The tailwind from inflation and productivity gains make sure of that.
The best result is if you buy when the close crosses above the 200-day moving average and hold for 200 days – slightly less than a year. This has returned an average of 10.93% per trade (dividend reinvested is not included thus understating the result.
The four tables are all moving average crossover systems. This is, of course, not he only way to test moving averages. Another useful tool can be to use a moving average as a trend filter. As an example, we recommend our pullback trading strategy.
What is a simple moving average (SMA)?
A simple moving average (SMA) is a simple average of the price of an asset over a specified period. The average is called “moving” because it is calculated continuously for any new price data recorded in each new trading session and plotted on the chart bar by bar, forming a line that moves along the chart as the average value changes.
The SMA is one of the primary indicators in technical analysis and is usually the easiest moving average to construct, which is why it is referred to as the “simple” moving average. The indicator is present on all trading platforms.
To give you an example of what a simple moving average looks like, we use a screenshot from Amibroker:
As you can see, the close crosses up and down frequently by using a 15-day moving average. There are many whipsaws and thus the win rate is low.
How do you calculate a simple moving average?
The formula for calculating the SMA is quite simple.
SMA = (P_{1 }+ P_{2} + P_{3}… + P_{n})/n
So, it is just the average closing price of an asset over the last “n” periods. To calculate it, you sum the closing prices of the asset over the chosen number of periods and then divide the sum by the number of periods.
For instance, let’s assume that Apple closed at $10, $11, $12, $11, $14 over the last five days. The simple moving average of Apple stock (AAPL) would be calculated as $10 + $11 + $12 + $11 + $14 divided by 5, which is equal to $11.6.
As time moves on, the first observation is taken away and replaced with a new one. For example, on the sixth day we have these observations:
$10 + $11 + $12 + $11 + $14 + $15
To calculate a new 5-day moving average we will have to exclude the first observation ($10) and replace it with $15:
$11 + $12 + $11 + $14 + $15
Thus, the new 5-day moving average is $12.6
Why use a simple moving average?
All moving averages aim to show the direction of the trend, and the SMA does that easily. It shows the direction the price of a security is moving based on previous prices. If the simple moving average points up, this means that the security’s price is increasing. If it is pointing down, it means that the security’s price is decreasing.
Also, it smooths out volatility better than most other moving average indicators. When the averaging period is long enough, say 100-day MA or 200-day MA, the indicator line can serve as a potential support or resistance level.
How to use a simple moving average
Every trading platform has a built-in simple moving average indicator. To use the indicator, you have to attach the indicator to the chart and adjust the settings to what you want. If you want the SMA to show a longer-term trend, you make the averaging period long, say 100 or 200. But if you want the indicator to follow the price more closely and show the short-term trend, you reduce the period to say 10 or 20.
How can you use a simple moving average?
You can use a simple moving average indicator to identify the price trend. If the SMA indicator line is pointing upward, with the price bars lying mostly above it, there is an upward trend, but if it is pointing downward, with the price bars lying mostly below it, there is a downward trend. When the SMA is flat, with the price swinging above and below it, the trend is sideways. The point is that you use the moving average purely mechanically by writing rules in your trading software.
Another thing you can do with the SMA indicator, especially a long-period (200-day SMA, for example) is to identify potential support and resistance levels. When the trend is upward, with the price bars lying above the SMA, the indicator line can serve as a potential support level. Likewise, when the trend is downward, with the price bars lying below the SMA, the indicator line can serve as a potential resistance level.
We have covered this in a separate article about moving averages.
Drawbacks with a simple moving average
The SMA is a lagging indicator. The reason is that the SMA is constructed using past closing prices. Thus, it simply displays a previous trend, which may not be predictive of future prices. You can reduce the lag by reducing the period setting, but that can also lead to many false signals. As always, there are only trade-offs in trading, no guarantees!
Relevant articles about moving averages strategies and backtests
Moving averages have been used for decades, perhaps even centuries.
Moving average strategies caught the interest of systematic trend followers in the 1970s when the first computers made computing easier. One of the first to use moving averages was Ed Seykota. However we believe moving average strategies were much more powerful 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 use moving averages profitably. But, as we have mentioned, there are plenty of different ways to use a moving average.
For your convenience, we have covered all moving averages with both 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)
- Double exponential moving average (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 simple moving average
We end the article with a few frequently asked questions about the simple moving average:
Q. What is a simple moving average (SMA)?
A. A simple moving average (SMA) is a widely used technical indicator that smooths out price data by creating a constantly updated average price. The SMA is calculated by taking the average closing price of a security over a specified number of time periods.
Q. How is the SMA calculated?
A. The SMA is calculated by adding up the closing prices of the security over a certain number of time periods and then dividing the total by that same number of time periods.
Q. What is the purpose of a SMA?
A. The purpose of a SMA is to provide an indication of the direction of a security’s trend and to help identify support and resistance levels.
Q. How do I interpret a SMA?
A. A rising SMA indicates that the security’s price is increasing and a falling SMA indicates that the security’s price is decreasing.
Q. What is the difference between a SMA and an exponential moving average (EMA)?
A. An exponential moving average (EMA) gives more weight to recent prices and less weight to historical prices than a SMA. As a result, an EMA will react more quickly to recent price changes than a SMA.
Q. What is the best simple moving average?
A. There is no best or worst simple moving average. You need to backtest to find out what is the best time frame for each particular asset.
Q. Is simple moving average 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. Should I use 200 SMA or EMA?
A. The 200-day moving average is a good indicator. We prefer to use the SMA and not the EMA.
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.
Simple moving average – conclusions
Our main takeaways from this exercise are that simple moving average strategies work well by buying when the close ends up below a short-term moving average and sell when it reverses and crosses above the same moving average.
Opposite, when you are using a long-term moving average, it’s best to buy when it crosses above the average and sell when it reverses and crosses below.