In this article I look at a simple 50 day moving average strategy and use the simulator from Amibroker to test the strategy on the stock market.
When it comes to technical analysis and trend following there is no shortage of naysayers.
Academics like to say that markets are perfectly efficient and that short term moves are nothing more than random. But if that is the case, how can so many stocks be riding high one minute then cut down the next?
Others believe that macro-economics drive prices and dismiss trend following out of hand. The fact is, however, trend following strategies work and they have been working for some time.
One very basic but popular trend following strategy is based on the 50 day moving average. In this article I look at whether this simple strategy can work in todays markets.
50 Day Moving Average Strategy
To test the 50 day moving average strategy I opened up the Amibroker trading platform and wrote some basic code. In this first test, the system buys a stock when the 50 day moving average crosses over the 200 day moving average. It sells when the 50 day moving average crosses back under.
(This a portfolio system that holds a maximum of 10 stocks at any one time. Risk is divided into 10 equal positions and commissions are set at $12 per trade. This was tested on stocks in the S&P 1500 US stock universe between August 2000 and August 2010. Trades are entered on the next day open.)
Buy = 50 day MA (close price) crosses over 200 day MA.
Sell = 50 day MA (close price) crosses under 200 day MA.
CAR: 16.94% Max Drawdown: -54%
As you can see, over stocks in the S&P 1500 between 2000 and 2010, this simple 50 day moving average strategy actually did very well.
Now let’s see how it does when the MA is substituted for an EMA (exponential moving average)
Buy = 50 day EMA crosses over 200 day EMA.
Sell = 50 day EMA crosses under 200 day EMA.
CAR: 3.58% Max Drawdown: -69%
Surprisingly, the EMA strategy does very poorly compared to the simple MA and delivers a much larger drawdown.
Next, let’s see how the same 2 strategies work on weekly data instead of daily data:
Buy = 50 week MA crosses over 200 week MA.
Sell = 50 week MA crosses under 200 week MA.
CAR: 11.63% Max Drawdown: -67%
Buy = 50 week EMA crosses over 200 week EMA.
Sell = 50 week EMA crosses under 200 week EMA.
CAR: 8.50% Max Drawdown: -63%
From these very rough and simple tests we can say that Test 1 looks the most promising. It produces the highest annual return (CAR) and the smallest drawdown.
Test 5 (out of sample):
Now it is important to see how the test does on out of sample data, to see whether this 50 day moving average strategy could actually work going foward. I therefore moved the test forward and ran the system between 1/1/2010 to 1/1/2014. The results are as shown below:
CAR: 11.42% Max Drawdown: -26%
These out of sample results look promising. The annual return is high and drawdown low. They are not as good as the insample (Test 1) and that is expected.
For this final test I wanted to see whether buying a stock when it moves above its 50 day moving average could be a worthwhile strategy. This is a strategy I’ve read about in the past. It buys when the open price moves above the 50 week MA and sells when the open price moves below the 50 week MA.
Buy = Open price crosses over 50 week MA
Sell = Open price crosses under 50 week MA
As you can see from the chart, this system doesn’t work well at all. It enters a lot of trades and suffers from too many whipsaws. This strategy did just as poorly when using EMA instead of MA and on daily data instead of weekly data.
It is impossible to say from these tests whether any of this strategies will work in the future, (though we can pretty much eliminate test 6 since it produces too many trades to be profitable). More testing needs to be done to verify these tests on different data sets and it is important to also include delisted stocks.
However, the simple 50 day moving average strategy shows enough promise here for further analysis. The adding of rules and filters may be able to turn this into a worthwhile trend following strategy.