Moving Average Slope Trading Strategy: Backtest and Evaluation
Moving average slope strategy backtest
Finding good signals in the random chaos called the financial market is not an easy job and as such, one has to seek out every possible way to analyze the markets. In the search for an edge in the market, people create more indicators from existing ones. One such derivative indicator is the moving average slope. And now, you may be wondering what that is. You might also wonder how you can make profitable moving average slope strategies in the markets?
Yes, moving average slope strategies do work. Our backtests show that a moving average slope can be used profitably for both mean-reversion and trend-following strategies on stocks.
The moving average slope is an indicator created by subtracting the moving average level n-periods ago from the current moving average level and dividing it by the time interval. For instance, you can get a 5-day slope of a 50-day simple moving average of the daily closing price by subtracting the value of the 50-day moving average 5 days ago from today’s value of the same 50-day moving average and dividing the difference by 5 days. The indicator is a great attempt at spotting when the price might be about to change direction by studying the strength (momentum) of the moving average.
Moving average slope strategy backtest and best settings
Before we go on to explain what a moving average slope 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 moving average slope strategy work? Can you make money by using moving average slope 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 N-day moving average slope crosses BELOW zero, we buy SPY at the close. We sell when the N-day moving average slope closes ABOVE zero. We use CAGR as the performance metric.
- Strategy 2: Opposite, when the N-day moving average slop crosses ABOVE zero, we buy SPY at the close. We sell when the N-day moving average slope closes BELOW zero. We use CAGR as the performance metric.
- Strategy 3: When the N-day moving average slope crosses BELOW zero we buy the close, and we sell after N-days. We use average gain per trade in percent to evaluate performance, not CAGR.
- Strategy 4: When the N-day moving average slop crosses ABOVE zero we buy the close, we sell after N-days. We use average gain per trade in percent to evaluate performance, not CAGR.
The results of the first two strategies look like this:
Strategy 1
MA Days |
5 |
10 |
25 |
50 |
100 |
200 |
CAR |
11.14 |
4.63 |
4.96 |
1.92 |
0.95 |
-0.64 |
MDD |
-36.62 |
-47.12 |
-45.81 |
-54.05 |
-55.39 |
-59.74 |
Strategy 2
MA Days |
5 |
10 |
25 |
50 |
100 |
200 |
CAR |
-1.19 |
4.85 |
4.57 |
7.52 |
8.43 |
6.4 |
MDD |
-65 |
-33.71 |
-37.83 |
-34.22 |
-33.72 |
-33.72 |
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. The crossover system in strategy 1 using a 5-day moving average, has one of the best CAGRs of all the moving averages we have tested (see further below for a full list).
Why do we reach that conclusion?
Because if we use a short moving average, the best strategy is to buy when the moving average slop drop below zero and sell when it turns around and closes above zero (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 11.14%, which is better than buy and hold even though the time spent in the market is substantially lower.
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 100-day moving average returns 8.43%, which is pretty decent.
The results from strategies 3 and 4 look like this (the results are not CAGR, but average gains per trade):
Strategy 3
MA \ Bars |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.49 |
0.77 |
1.5 |
2.39 |
4.32 |
8.49 |
10 |
0.41 |
0.27 |
0.72 |
2.09 |
3.88 |
7.55 |
25 |
0.83 |
0.19 |
1.24 |
2.3 |
3.73 |
7.24 |
50 |
0.63 |
1.19 |
1.6 |
3.53 |
6.02 |
12.22 |
100 |
1.06 |
1.2 |
1.87 |
4.52 |
6.15 |
6.15 |
200 |
-0.45 |
-0.71 |
0.95 |
0.14 |
-6.37 |
-12.67 |
Strategy 4
MA \ Bars |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.01 |
0.1 |
0.82 |
2.02 |
4.27 |
8.04 |
10 |
0.03 |
0.29 |
0.67 |
1.01 |
3.37 |
7.41 |
25 |
0.1 |
0.12 |
0.41 |
1.17 |
4.14 |
6.53 |
50 |
0.12 |
0.27 |
1.89 |
2.58 |
5.7 |
13.59 |
100 |
0.59 |
0.55 |
1.8 |
2.11 |
3.99 |
9.55 |
200 |
0.34 |
-0.64 |
-0.03 |
3.13 |
1.18 |
7.08 |
The 50-day average is the best – by far. Of all the moving averages we have tested, this has returned the most. Strategy 4, which buys when the moving average slope breaks above zero, has an average return of 13.59% over the next 200 days – much better than buy and hold.
However, be aware that we have tested just four strategies of the moving average. There are basically unlimited ways you can use a moving average and your imagination is probably the most restricting factor!
What is the moving average slope (MA Slope)?
The moving average slope is an indicator you can create from a moving average indicator or moving average indicators you are already using. For any given moving average, you can get the slope by subtracting the moving average level n-periods ago from the current moving average level and dividing by the time interval.
For example, you can get a 5-day slope of a 50-day simple moving average of the daily closing price by subtracting the value of the 50-day moving average 5 days ago from today’s value of the same 50-day moving average and dividing by the time interval. It is an attempt at using insights from geometry to study the momentum of the moving average.
The indicator can help to monitor the strength of the trend and spot when the price might be about to change direction by showing the strength (momentum) of the moving average. In other words, the MA Slope is a measure of the momentum of the moving average indicator, and as such, can tell the strength of the prevailing trend.
Whether the indicator is more useful than combining two MAs, n-periods apart, and using the crossover strategy depends on the trader’s preference. But as with the crossover method, the moving average slope can tell you if the trend is going up, down, or staying flat, and better still if the trend is losing momentum in its current direction.
How to calculate the slope of a moving average
In time series, the slope of two successive points in time is gotten by just subtracting the last value from the one preceding it. But when there is a wider interval, say 5 points in time, we have to use the below formula:
Slope = change in price / change in time
Bringing this to a moving average slope, the formula can be written as:
MA Slope = change in moving average value / time interval
Or
MA Slope = [MA_{c} – MA_{n}]/n
Where:
MA_{c} = current value of the moving average
MA_{n} = the value of the moving average n-periods ago
n = number of periods ago
Why use moving average slope?
The moving average slope can tell you the momentum of the moving average relative to some time in the past. That is, when the moving average is increasing in value, staying flat, or decreasing. This, in turn, tells you the strength of the trend.
Also, when using two MAs of different periods to indicate the short-term and long-term trends, their slopes can show you when both the short-term and long-term trends are in the same direction, which presents a better and less-risky time to enter a trade in that direction.
How to use the moving average slope
Ordinarily, when using a moving average indicator, you can visually gauge the slope of the moving average — at least, you can see whether the slope is upward (uptrend), flat (sideways), or downward (downtrend). In fact, if you are observant, you can see when the slope is getting steeper (stronger trend) or less steep (declining trend).
However, you can code or pay someone to code a custom indicator that measures slope and displays it as an indicator line on the chart. This can make the use of moving average slope easier for you.
How can you use the slope of a moving average in trading?
There are many ways you can use the slope of a moving average in guiding your trading decisions. The simplest one is to find the direction of the trend when using a single moving average. In this case, if the slope is upward, the market is likely in an uptrend, and if it is downward, the market is likely in a downtrend. When the slope is flat, the market is probably range-bound.
You can also employ the strategy of the relative slope by using two moving averages of different periods to show the long-term and short-term trends. In this case, when the slope of both moving averages is upward, it means that both the short-term and long-term trends are in the same direction: upward. So, it is safe to go long. If the long-term MA Slope is upward, but the short-term one is downward, it may be best to wait for both to align before you make a trade.
Similarly, if both long-term and short-term MA slopes are downward, it may be safe to take a short position in the market.
Drawbacks of using the moving average slope
As with any moving average-based indicator, the MA Slope is also plagued by the lag factor. As a result, the signal may come too late after the price has progressed in the new trend direction.
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)
- Double exponential moving average (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 moving average slope
We end the article with a few frequently asked questions:
What is a moving average slope strategy?
A moving average slope strategy is a technical analysis strategy that focuses on the slope of a moving average line. It attempts to identify trends in the market by measuring the rate of change of the moving average. As such, it differs a little bit from the most known moving averages.
How does a moving average slope strategy work?
A moving average slope strategy works by measuring the rate of change of a moving average line. It will attempt to detect when the slope of the moving average is increasing or decreasing, which can indicate a trend in the market.
What types of moving averages are used in a moving average slope strategy?
The most commonly used types of moving averages in a moving average slope strategy are simple moving averages (SMA) and exponential moving averages (EMA).
How does a trader use a moving average slope strategy?
A trader can use a moving average slope strategy to detect changes in the market trend. For example, if the slope of the moving average is increasing, it may indicate an uptrend in the market, while a decreasing slope may indicate a downtrend.
But of course, there is no limits on what you can backtest yourself. Only your imagination limits you!
What are the risks of using a moving average slope strategy?
As with any trading strategy, there are risks associated with using a moving average slope strategy. These risks include the potential for false signals and whipsaws, which can lead to losses. Additionally, the strategy can be subject to changes in market conditions, which can have an effect on the accuracy of the signals generated.
As a rule of thumb, all moving average strategies have plenty of whipsaws and a low win rate.
Does the moving average slop 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 a moving average slop works pretty well on stocks! As a matter of act, our backtests reveal that it’s the best-performing moving average!
Moving average slope – takeaways
Our takeaway from the backtests is that moving average slope strategies work well if you buy on weakness (when the average turns negative) and sell on strength (when the average turns positive) 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.
FAQ:
How does a moving average slope strategy work?
A moving average slope strategy is a technical analysis approach that focuses on the slope of a moving average line. A moving average slope strategy works by analyzing the rate of change of a moving average line. It helps traders detect when the slope of the moving average is increasing or decreasing, indicating potential trends in the market.
How does a trader use a moving average slope strategy?
The most commonly used types of moving averages in a moving average slope strategy are simple moving averages (SMA) and exponential moving averages (EMA). Traders use a moving average slope strategy to identify changes in market trends. For example, an increasing slope may indicate an uptrend, while a decreasing slope may suggest a downtrend.
How to calculate the slope of a moving average?
The moving average slope provides insights into the momentum of the moving average, indicating the strength of the prevailing trend. The slope of a moving average is calculated by subtracting the value of the moving average n-periods ago from the current value and dividing by the time interval. The formula is MA Slope = (MAc – MAn) / n.