Perfecting the Golden Cross Strategy — Choosing Values for the 2 MAs

Visualising the returns of different combinations of moving average intervals

Justus Ip
5 min readAug 29, 2022

What is the Golden Cross Strategy?

The Golden Cross Strategy (GCS) is a popular algorithmic trading strategy in the financial market. It involves the use of two moving average (MA) parameters to determine when to buy or sell a stock. Specifically, a short-term MA crossing over a long-term MA triggers a buy, while the opposite triggers a sell. GCS has been shown to outperform a simple buy-and-hold strategy, making it a profitable choice for long-term investment.

Investopedia / Julie Bang

To use GCS, we define the two moving average (MA) parameters, n1 and n2. For example, (20, 50). When the 20-day moving average crosses the 50-day moving average, we buy it — otherwise, we sell it.

The selection of n1 and n2 plays a crucial role in the success of the strategy. Even a slight modification of these parameters can result in vastly different outcomes. For example, if we run GCS on Microsoft stock (NASDAQ: MSFT) with simple moving average (SMA) indicators of intervals (25, 60) within the last 2 years, we yield a staggering total return of +94.7%.

GCS(25, 60) on MSFT from 02/01/2020 to 10/08/2022. +94.7% return.

However, if we slightly tweak the parameters to (25, 50), we yield a return of -20.5%.

GCS(25, 50) on MSFT from 02/01/2020 to 10/08/2022. -20.5% return.

We kept n1 unchanged, n2 changed only from 60 to 50, and we have already lost a return of 115%, resulting in a negative return. I have always been wondering if there is any correlation between the two parameters. Is there a rule for selecting the set of values to ensure a sustainable return? In the following, I attempt to explore these questions and observe the correlation between the two parameters.

Visualising Returns

With the help of the Python back-testing library backtest.py and the beautiful graph-plotting library Seaborn, I generated a heatmap of the return of GCS on Google stock (Alphabet Inc. Class C, NASDAQ: GOOG) with different combinations of SMA intervals. The back-testing period would be again from 02/01/2020 to 10/08/2022, with initial capital of $100,000 USD and a commission of 0.2%.

In the graph, y-axis and x-axis represent n1 and n2 respectively, i.e., the shorter and the longer SMA intervals. Individual cells represent the percentage return (%) of GCS with the corresponding SMA parameters. Cells with a blue background represent a positive return, and red represents a negative return. The darker the colour, the more intense the return is.

Returns of GCS(n1, n2) on GOOG from 02/01/2020 to 10/08/2022.

The graph shows some very interesting characteristics. Let’s annotate the regions and analyse each of them.

Above graph annotated.

The graph can be divided into 3 regions. Region a) has no numerical values. Being the shorter and longer SMA intervals respectively, n1 is supposed to be smaller than n2, and since n1 > n2 in this region, I hid the output of this region. Region b) and c) are the interesting parts. In region b), the region stretches from the bottom-left to the opposite corner. There are some dark blue areas accumulated at the centre, but it slowly fades away at both ends. Region c) is mainly composed of pale regions, and in the tip at the bottom-right corner, there is a patch of negative returns as well. There is a clear boundary between regions b) and c).

Let’s plot the graph of some other various instruments and see if they also show similar contours.

Returns of GCS(n1, n2) on on various instruments from 02/01/2020 to 10/08/2022. From top-left to bottom-right: Bitcoin/USD, APPL, META, MSFT, NVDA, TSLA.

In graphs of other various hot stocks and Bitcoin, they share surprisingly similar features with the first one. All of them present regions a), b) and c) clearly. Some of them have thicker region b)s, and some of them have narrow ones which ended earlier than others.

General Rule

Is there any rule to be derived from these graphs? Firstly, large values should be avoided with respect to your investment period. In my 2-year back-testing period, values such as 100 or above will usually result in insignificant returns. Moreover, there should not be a great difference between n1 and n2. Extreme values should be avoided, e.g., (10, 80), which lies at the bottom-right of the graph, and it is something that you would want to avoid. n1 and n2 should be proportionate with only a little difference. This makes the pair of values lie at the diagonal edge of region b) which ensures a usually great return.

There are also special cases, as shown in the graphs of Amazon and Netflix, where the general rule does not apply due to their recent decline in the market. These are the stocks to be avoided anyway when investing bull.

Returns of GCS(n1, n2) on on various instruments from 02/01/2020 to 10/08/2022. Left: AMZN, right: NFLX

In conclusion, the Golden Cross Strategy is a powerful tool for algorithmic trading in the financial market. By selecting the right values for the two moving average parameters, traders can achieve great returns on their investments. Our analysis shows that there are certain guidelines to follow when choosing these values, such as avoiding extreme values and selecting proportionate values with a little difference. However, traders should also be aware of special cases, such as stocks experiencing a decline in the market, which may require a different approach.

--

--

Justus Ip
Justus Ip

Written by Justus Ip

Year 4 Computer Science Student at the University of Hong Kong.

No responses yet