The traditional moving average crossover trading has been around for decades and is surprisingly
still a viable trading strategy that manages to catch some of biggest trends in the stock
markets. One of the most popular moving average crossover strategies is to trade 2 simple
moving averages one with period of 50 days and other with period of 200 days, as shown
on the chart But how about the other periods? There must
be other combinations of periods of moving averages that perform better than the traditional
50 and 200-day setting. In today s video, I m going to run an optimisation of a simple
moving average crossover trading system by testing various moving average lengths to
find out which ones performed the best. I m going to do this on all S&P500 stocks starting
from 2003 and so the results will be based on a lot of data
Before I do that if you re new to may channel, my name is David and I trade in a fully systematic
way and publish videos where I quantify various trading systems or tools by backtesting them
using a specialised software. If you re looking for inspiration to take away for your own
trading system development, then definitely subscribe to my channel.
Now - looking at this chart here, this strategy would buy when the turqiouse line, which is
the 50-day moving average, crossed above the orange line, which is the 200-day moving average.
The position is held until the crossover takes place in the opposite direction, meaning that
this strategy is a simple trend-following strategy. Let s take these moving averages
and test a number of various combinations let s test all possible combinations, starting
from period of 50 days up to 250 days for both averages. What I want to do here is to
find out which combination performed the best.
I ve started the optimisation in the software of my choice, called Amibroker, where the
optimisation is run to start from 2003 and it is being conducted on all S&P500 stocks.
Important thing to bear in mind is that all my tests, including this optimisation take
the historical index constituents into the account if you don t know what this is I suggest
that you do some research into this as it s an extremely important concept to understand
when backtesting trading systems in stocks. Now that I got the results of my simple moving
average crossover optimisation ready, let s find out which combination performed the
best. The criteria to determine this I will use is the ratio between the average annual
return to the maximum drawdown, which is located in the column that I ve highlighted on the
screen. The best combination is a simple moving average of 70 days combined with simple moving
average of 210 days, where the buy setup is generated when the 70-day moving average crosses
above the 210-day moving average. As I said, all combinations are tested on all S&P 500
stocks, and all combinations include a couple of other rules which I will put in the description
of the video for you. Let s have a look at an example trade two
moving averages are plotted on the chart, where the shorter, 70-day moving average crossed
above the longer one here, which would act as a signal to buy this particular stock.
The stock would be held up until this point, where we can see that the 70-day moving average
crossed below the 210-day moving average which acts as a signal to sell the stock. Now, moving
average crossovers have been publicly known for a long time and I ve always been quite
sceptical about them, however there definitely is some sort of a merit to them the key is
to experiment with them yourself and come up with your own version of moving average
crossover system rather than just blindly trading one without validating it first.
Let s look at the equity curve of this particular moving average variant to see how it performs
when compared to the traditional 50 and 200 moving average crossover system. The 70 and
210-day moving average crossover variant is plotted in turquoise colour, and we can observe
that it s performing better than the benchmark, which is the traditional 50 and 200-day variant.
However, by looking at this equity curve this is still not something that I would personally
be looking to trade and so I definitely would be looking to fine tune this system a little
bit. However do bear in mind that any changes you make and optimisations that you conduct
need to be done on what s called an in-sample data which is not what I m doing in this particular
video here since I m optimising on an entire sample and that s not how I would normally
do things. This video is not about how to optimise trading systems but rather about
giving your some inspiration as to where to start when looking for a simple moving average
crossover system or simply a starter moving average periods that you can use as a foundation
for your own system. But now, I ve used same moving average periods
for both buy and sell signals, where this simple system buys when the 70-day moving
average crosses above the 210-day moving average, and sells when the 70-day average crosses
below the 210-day one. However, how about we use a different set of averages for the
exit with a view to improve the performance, meaning that we would use the 70-day and 210-day
moving average crossover to buy, but use different ones to sell?
Let s have a look I m going to run another optimisation but this time, it s testing the
exit side only the entry side is fixed to 70 and 210-day moving average crossover. All
other settings are identical to the previous test I made and I ve put the specs in the
video description. Again, the criteria I m using is the ratio between the average annual
return to the size of the maximum drawdown where the higher ratio, the better. The best
performing moving average crossover variant for exit side of our simple moving average
crossover system is 110-day and 230-day moving average. This means that when the 110-day
moving averages crosses below the 230-day moving average, sell signal is generated and
the position is closed.
Let s have a look at the final equity curves. The orange line is the equity curve of the
traditional moving average crossover that s using the 50-day and 200-day moving averages.
The turquoise line is the result of the first optimisation I ran in this video using the
70-day and 210-day simple moving averages, where the buy signal is generated when the
shorter moving average crosses above the longer one, and the sell signal is generated when
the shorter moving average crosses below the longer one. The green equity curve is the
best performing candidate of the second optimisation I ran where the buy signal is the same as
the previous one so 70-day moving average crossing above 210-day moving average, however
the sell signal is different. The exit side of this system uses a different set of moving
averages 110-day and 230-day moving average, where the sell signal is generated when the
110-day moving crosses below the 230-day moving average. All other rules are identical and
I ve put them in the description of this video. Again, the optimisations I made were made
on the entire data sample which is not how I would normally do this, as obviously by
simply picking the best variants of a trading system on the entire data sample, we re running
into a risk of curve-fitting. That may result in the system being profitable in the backtest,
but failing in the future when applied on unseen, real-time data. I may do a video on
how to optimise strategies some time, but in this video I wanted to demonstrate that
investigating different indicator lookback periods definitely pays off and I also wanted
to provide you with a moving average combination that would act as foundation for your own
system. The last thing is the comparison of the backtest
reports the one on the left shows the final optimised variant of a simple moving average
crossover, compared to the traditional 50-day and 200-day moving average crossover on the
right. We managed to double the average annual return, and, at the same time, actually half
the maximum drawdown which is quite impressive. That s it for today, thanks for watching,
David at Critical Trading, signing out