Last weekend I received an email from an EdgeRater user asking if it was possible to test a system that he had seen described in a YouTube video, the video was 10 years old and so I thought it would be interesting to see how it has performed since the video was made using data that could not have been known back then.
The system is a simple long term timing signal for the S&P 500 index. Here are the rules:
- Go long when the 20 week MA crosses up through the 50 Week MA by more than 1%
- Exit when the 20 week MA crosses down through the 50 Week MA by more than 1%
Basically a Moving average crossover system with some porosity built around the longer term moving average.
Here’s a link to the video for those interested:
Testing the system in EdgeRater
In order to test this system in EdgeRater we need to generate Entry signals and Exit Signals in the Entries and Exits tab
As you can see here a custom script called WeeklyMACrossUpPct has been dropped into the security selector area. The code in this script is as follows:
MA1:= FML('MA(SHORTPERIOD)#WEEK1'); MA2:= FML('MA(LONGPERIOD)#WEEK1'); MALOWERBAND:= MA2 * (1 - X/100); MAUPPERBAND:= MA2 * (1 + X/100); event: CROSS(MA1, MAUPPERBAND);
There are 3 parameters to this script
- SHORTPERIOD with a default value of 20
- LONGPERIOD with a default value of 50
- X with a default value of 1
SHORTPERIOD and LONGPERIOD are used to set the weekly moving average periods and X is used to allow testing of variations of the 1% porosity band around the 50 MA.
The Exit script is as follows:
MA1:= FML('MA(SHORTPERIOD)#WEEK1'); MA2:= FML('MA(LONGPERIOD)#WEEK1'); MALOWERBAND:= MA2 * (1 - X/100); MAUPPERBAND:= MA2 * (1 + X/100); event: CROSS(MALOWERBAND, MA1);
Adding this to the Exits portion of the Entries and Exits tab produces the following events:
Now that we have generated a set of entry and exit signals we can head over to the Trade Simulation tab and knit these together to generate a trade list and statistics report:
Here you can see a comparison between the daily equity of the simulation vs the actual SPX. Note how the system goes flat during the SPX drawdown phases.
Walk Forward Testing
The original video was produced in 2008. Since then the system has produced 4 trades with the following P/Ls:
Also note that in the video the actual dates mentioned are off by a few months here and there and that also the initial stated gain of 76% on the trade that ended in 2008 was only a 38% gain. Other than that the video description of results seems accurate.
This timing system has been profitable 6 times out of 7 and would have kept you out of the market during the 2001-2003 bear market and the 2008 bear market. A buy and hold strategy on the SPX from 1990 to August 2018 would have turned $100,000 into $748,000 but also would have had significant drawdowns during the bear markets. This timing system would have turned $100,000 into $772,000 and kept you out of those major drawdown phases.
You can easily test this strategy in EdgeRater and also variations around the strategy. Bear in mind that there were so few signals here that it’s hard to infer any statistical significance but the general principal of avoiding the damaging bear markets may lead to this being a good overall market timing signal. For example, if this system is out of the market then maybe don’t consider long trades in any stocks.