In the markets, traders overlay moving averages on their price charts in order to show when a market is trending and to provide objective buy and sell signals.
If a moving average is moving upwards it shows that in general, the market is trending higher, whereas if a moving average is moving downwards it shows that the market is trending lower.
Moving average crossovers are also used to identify changes in trend. So if a fast moving average such as the 50 day moving average crosses over a slower moving average such as the 200 day moving average, the market can be said to have changed from a downward trend to a new uptrend. And this is known to traders as a Golden Cross.
The opposite of this occurs when the 50 day moving average crosses under the 200 day moving average and this is known as a Death Cross.
Using the moving average as a filter
Some traders believe that the Golden Cross is a strong signal to buy the stock market and a Death Cross is a strong signal to sell, based on the assumption that financial markets move in medium to long-term trends.
If you use these two signals you can capture gains when the market is moving higher, and move into cash when the market is going lower. So let’s load up some data now and see how this stock market timing strategy has actually played out over the last 100 years.
So, first of all I’m going to load up some historical daily data for the Dow Jones Industrial Average into Amibroker and I’m going to calculate the buy and hold returns between 1900 and 2014.
So as you can see from the results below, the annualised nominal return from buy and hold with the Dow Jones is 5.22%, and the maximum drawdown is 89%, which occurred during the Great Depression. (Drawdown is a way of measuring the peak-to-trough decline of an investment. So in this case, the buy and hold investment would have lost 89% from the peak in 1929 to the trough in 1932).
*It’s worth mentioning that these are the nominal returns. To get the actual, real-life returns, it is necessary to adjust the data for re-invested dividends as well as for inflation. It is possible to do this adjustment, but for daily data – needed here – it is not so easy. Therefore, nominal returns will be used. Just bear in mind that the returns may be slightly higher in real life due to dividends. In general, the stock market has been shown to return around 6%-7% over the very long term.
Running the crossover strategy
Now, instead of using a buy and hold approach we will only buy the Dow when the 50-day moving average crosses over the 200-day moving average (a Golden Cross). And we will sell the market whenever the 50-day MA crosses under the 200-day MA ( a Death Cross).
You can see from the below results that the moving average filter has worked:
So, instead of just buying and holding the index, we’ve actually made 81 trades over the time period. And the next chart shows come of the more recent trades. Green arrows are buy signals and red arrows are sell signals.
You can see that the moving average actually got us out of the market right before the credit crisis. And it got us back into the market on the 1 July 2009.
Now let’s do the same thing but on a different data set.
So in this case, I’ll run the buy and hold strategy on the S&P 500 Index between 1955 and 2014.
And you can see from the results that the annualised return from buy and hold is 6.65% with a drawdown of -57% for the time period.
And here the buy and hold gives us a 1.65% annual return and a drawdown from the credit crunch of -57%. This results in a very unstable equity curve as you can see below:
Meanwhile, the moving average crossover strategy results in an annual return of 6.06% with a drawdown of just 20%. And as you can see, the equity curve with the moving average crossover is a lot less scary. Again, the moving average strategy has kept us out of the market during most of the market crash in 2008.
MA crossover strategy: Summary
Overall, I’d say that this is a win for the moving average crossover as a stock market timing strategy.
We have run three tests and the popular Golden Cross strategy has helped us to time the market better than the buy and hold on every occasion. For me, the most important thing is that it has sharply reduced our exposure to losses during bear markets.
Of course, we could go further down this road and look at different moving average speeds and different timeframes, but I don’t want to do too much optimising so I’ll leave it up to you to investigate yourself.
Using the broader market to time a portfolio
So now we have seen how the simple moving average can help when timing the stock market. But what if we are not interested in buying the stock market itself but rather a portfolio of different stocks.
Maybe the broader stock market can help time our individual stock trades too.
In order to test this, I have set up a very simple stock portfolio strategy based on momentum and 52-week highs.
Very simply, whenever a stock closes at a new 52-week high that stock is added to the portfolio on the next open. Whenever it closes at a new 26 week low, the stock is sold on the next open and it drops off the portfolio.
The portfolio can hold a maximum of 10 stocks at any one time and each one is weighted equally with no margin used. The strategy chooses stocks from the S&P 500 universe and commissions are set at $10 per trade with a starting capital of $10,000.
Test one results
Running this basic portfolio strategy resulted in an annual return of 9.69% between 2000 and 2014, which is pretty good.
Using the S&P 500 as a filter
Many practitioners believe that it’s best to only buy stocks when the broader market is trending upwards and to sell those stocks when the market is heading south or in a bear trend.
A market filter might therefore be able to improve a simple momentum strategy like this one by taking the portfolio into cash when the broader stock market is moving lower.
So what if we introduce a market filter like before so that we only buy stocks when the S&P 500 is in an uptrend?
For the next test, stocks are only bought and added to the portfolio if the 50-day moving average of the S&P 500 is above it’s 200-day moving average.
If the 50-day moving average of the S&P 500 crosses under it’s 200-day moving average, all stocks are sold and the portfolio moves into cash.
As soon as a new golden cross occurs in the S&P 500, the system is allowed to begin buying stocks once more.
Running this strategy with the S&P 500 market filter turned on results in a return of 7.47% and a drawdown of -12%.
So although the annual return has gone down, the drawdown is vastly improved and the equity curve is a great deal smoother:
This time, the system will buy a stock whenever it makes a 52 week high, just like the first test. It will then sell all stocks in the portfolio whenever a Death Cross occurs in the S&P 500.
In this way, positions are cut when the broader market declines. However, there is no filter for long trades like test two.
In other words, the market does not have to be in a fully formed uptrend to initiate new trades and this gives the strategy a bit more flexibility and exposure.
Running this test produced an annual return of 5.49% and a drawdown of -38%. Compared to the original strategy, the drawdown has decreased but the annual return has also suffered.
It seems to me that the problem with test three, is that the system is exiting winning positions too early. Just because the broader market is heading down does not mean that there are not individual stocks outperforming the benchmark.
Therefore in the next test, I do the opposite. Stocks are only bought if the S&P 500 is in an uptrend (the 50 MA is above the 200 MA) but they are not sold if the S&P 500 moves into a downtrend.
This gives a better annual return of 8.78% and a maximum drawdown of -29%.
Next I will quickly take each of these tests back to the beginning of the data set to see what happens on a longer time frame.
(By the way, I am using stocks from the S&P 500 universe that includes historical constituents, this is provided by Norgate Premium Data.)
Test 1, between 1985 and 2014, produced an annual return of 10.01% with a maximum drawdown of -33%. This is the original system with no market timing filter.
Test 2, between 1985 and 2014, produced an annual return of 6.93% with a -34% drawdown – so this was much much worse than our previous result. From looking at the results and equity curve, the buy criteria may be too strict.
Test 3, between 1985 and 2014, produced an annual return of 3.73% with a maximum drawdown of -31%. Again, this is a bad result for the market timing filter.
Test 4, between 1985 and 2014, produced an annual return of 8.71% and a maximum drawdown of -31%.
Portfolio filter: Summary
Overall, the moving average filter appears to have some merit when used to trade the broader stock market. However, the case is not so clear-cut when used as part of a portfolio strategy.
When timing the overall market, the crossover strategy improves both drawdown and return in most cases. But when using the crossover as a filter for a momentum portfolio strategy, there is no clear improvement in either.
One reason for this could be that the momentum portfolio already has it’s own exit criteria built into the system. Using an extra market filter adds extra complexity and might therefore be overkill. One thing the momentum portfolio needs to succeed is to be able to capture long tail profits in stocks so the cutting short of trades is not always helpful.
It is also possible that the market filter criteria is simply too strict and by changing the parameters slightly, we might be able to improve results.
That may be so, but these results do suggest one thing at least – that the market filter strategy is not necessarily a magic bullet for portfolio systems, and this also confirms my own previous findings.
Thank You For Reading
Joe Marwood is an independent trader and the founder of Decoding Markets. He worked as a professional futures trader and has a passion for investing and building mechanical trading strategies. If you are interested in more quantitative trading strategies, investing ideas and tutorials make sure to check out our program Marwood Research.
This post expresses the opinions of the writer and is for information, entertainment purposes only. Joe Marwood is not a registered financial advisor or certified analyst. The reader agrees to assume all risk resulting from the application of any of the information provided. Past performance is not a reliable indicator of future returns and financial trading is full of risk. Margin trading can lead to losses more than in your account. Mistakes in backtesting and presenting of analysis regularly occur. Please read the Full disclaimer.