Home Moving average strategies Moving average Slope – Trading Strategy Backtest (Does it work?)

# Moving average Slope – Trading Strategy Backtest (Does it work?)

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

Strategy 2

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

Strategy 4

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 = [MAc – MAn]/n

Where:

MAc = current value of the moving average

MAn = 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:

We have also published relevant trading moving average strategies:

## 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.