Introducing Beyond the Charts
Welcome to the Trade Risk’s brand new educational series, Beyond the Charts! It is designed to give you insights into our research process, which for nearly a decade has helped fine-tune our expertise and products, such as the market-beating Merlin trading strategy.
We start by asking questions as broad as, “Is there really such a thing as a Santa Claus rally?” to as specific as buying a breakout after a particular type of consolidation. We then research our answers by following the steps to the good old fashioned scientific method:
- Observe the market
- Form a hypothesis
- Ask a question
- Gather our data
- Write the code
- Conduct the experiment
- Analyze the results
- Draw conclusions
We hope the technical tools and code we’ll share with you throughout this series will help you become a more informed investor and, please note, the conclusions we draw throughout this series should be seen only as a starting point to additional independent research.
In this first episode, we explore and evaluate the golden cross trading strategy by asking two questions:
- Is trading the golden cross profitable?
- If it is, is it worth trading?
We ask the follow-up question (2) because a strategy can be profitable but that doesn’t mean it’s better than alternative investment choices like a 60/40 portfolio or other market timing strategies.
What is the golden cross?
The golden cross involves the two most popular technical indicators traders use on their charts: a 50-day and a 200-day moving average. A golden cross is said to occur when the short-term moving average (50-day) crosses above the long-term (200-day) moving average.
In contrast, a death cross happens when the short-term moving average crosses below the long-term moving average. Golden crosses and death crosses can occur on any underlying stock but it is most widely watched on the major market indices.
Today, we are going to code a strategy from scratch which executes trades when golden crosses and death crosses occur.
Tools & resources used in this experiment
- NinjaTrader 8: This is the backtesting platform we’ll be using to generate our signals and test our strategy.
- Microsoft Excel: After we run our strategy in NinjaTrader, we’ll export the reports to Excel and analyze results.
- Norgate: This is where our data comes from for this experiment and it’s our recommended source for building and testing strategies (affiliate/referral link).
- Github: All of the strategy code can be found and downloaded here.
The in-depth tutorial
The following video lesson is where we go into all of the detail setting up the experiment, writing the code, and using our various tools and programs. If you want the in-depth walkthrough we recommend continuing from this point on with the video. We also have timestamps in the description of the video in case you want to jump around.
How we constructed the golden cross strategy
The strategy is composed of five key methods:
- OnBarUpdate(): the main strategy method
- BuySellRules(): defines the trading rules:
- Buy when golden cross occurs (50-day moving average crosses above 200-day moving average)
- Exit the long position when death cross occurs (50-day moving average crosses below 200-day moving average)
- ComputeShareSize(): calculate the number of shares to purchase using 100% of the current account equity
- CalculatePerformance(): track running realized and unrealized profit as well as the current account balance
- OutputPerformance(): print out dates and balances to the output window for analysis
How we set up the golden cross testing environment
|Golden cross test||Parameters|
|Testing universe||DIA ETF (total return)|
|Backtest 1||13 years: 2005 to 2018|
|Backtest 2||20 years: 2000 to 2020|
Golden cross strategy backtest 1: October 2005 – December 2018
During our first backtest between October 2005 and December 2018, the golden cross strategy yielded some pretty strong results. We began the test with a $10,000 hypothetical account balance, assume 100% invested on each signal, with no shorting on death crosses, only exits of our long position.
Here were the results:
Not sure how to interpret some of these measurements? Head on over to our trading system performance glossary.
You can see the ending balance of our strategy versus our buy and hold benchmark ended with very similar values ($29,679 versus $30,791) but it managed to achieve those returns with a significantly smaller max drawdown (-20.3% versus -51.70%) and a much improved Sharpe ratio (0.70 versus 0.48).
The primary driver of this risk-adjusted outperformance for the golden cross strategy was sidestepping the bear market of 2008. These results look good, so we set out to run another test pulling in more historical data.
Golden cross strategy backtest 2: October 2000 – June 2020
This backtest almost doubles our testing period and includes major market events such as the tech bubble and bear market in the early 2000s and the fastest drop in stock market history from all-time highs into a bear market in the first quarter of 2020.
What you’ll notice immediately is that both the strategy and benchmark compound annual growth rate (CAGR) dropped from our first backtest with the benchmark falling from 8.90% to 6.5% and the strategy from 8.60% to 3.90%.
What was equally disappointing to see from the strategy perspective was the defensiveness or risk-adjusted qualities that it had in our first test also deteriorated. The maximum drawdown nearly doubled from -20.30% to -39.1% while the benchmark stayed consistent with our first test.
This additional market data gave the golden cross strategy difficulties in both the bear market of the 2000-2002 period as well as the 2020 COVID-19 bear market.
Here’s how the equity curves stack up between the strategy and benchmark over this 20-year time period:
Is trading the golden cross a profitable strategy?
Yes – in both tests over the past 20 years of market data using the Dow Jones Industrial Average the strategy generated a profit.
Is it worth trading or investing in the golden cross strategy?
If we had stopped testing after our first 13-year backtest then we probably could have had a yes to this question as well given the strong risk-adjusted performance profile.
However, after we pulled in more data and observed the strategy over new market environments we can see the golden cross isn’t as robust as it initially appeared.
The golden cross is a trend following market timing strategy and our second test shows where this type of system has some difficulties: choppy sideways market environments, and extreme v-shape moves in a short period of time.
Ultimately, we believe there are better options out there to invest in over this particular timing strategy.
The golden cross and death cross have long had great bull and bear market narratives associated with them, so that means you’re probably going to continue to see lots of dramatic and overstated headlines when they occur in the future. But now you know that if you were to follow those signals and trade the crosses like we did in this experiment you might be left quite disappointed with your returns over the long-term.
Of course, there are many more time periods and markets you would want to continue your research with, so if you want to learn and test more, be sure to download our strategy code to continue your investigation.
I hope you enjoyed the experiment. If you have any questions, comments, or feedback for future Beyond the Charts episodes, please leave us a comment below.
Enjoy what you read? Share it below and be sure to tag @thetraderisk.
Posted in Article, Research, Trading Education, Trading Strategy, Trading Success
Tagged with Backtests, Beyond the Charts, Entries and Exits, Market Environments, Microsoft Excel, Moving Averages, NinjaTrader, Systematic Trading, Technical Analysis, Trend Following, Video Lesson