Geometric Moving Average GMA – Trading Strategy Backtest (Does it work?)
Geometric moving average strategy backtest
There are different ways of getting the moving average of a time series. While the simple and exponential methods of calculating the moving average are more common in the trading world, it is also possible to get the geometric mean of the price series. But what does the geometric moving average entail? Can we make profitable geometric moving average strategies in the markets?
Yes, simple moving average strategies do work. Our backtests show that a geometric moving average can be used profitably for both mean-reversion and trend-following strategies on stocks.
The geometric moving average is a type of moving average that calculates the geometric mean of the previous n-periods of the price time series. Unlike the simple moving average that uses the arithmetic mean to continuously calculate the moving average as new price data comes in, the geometric moving average uses the geometric mean formula to get the moving average of the price data as new ones come in. Since the geometric mean has a compounding effect, investors usually consider it a more accurate measure of returns than the arithmetic mean.
Geometric moving average strategy backtest and best settings
Before we go on to explain what a geomtric moving average is and how you can calculate it, we go straight to the essence of what this website is all about: quantified backtests.
Our hypothesis is simple:
Does a geometric moving average strategy work? Can you make money by using geometric moving averages strategies?
We look at the most traded instrument in the world: the S&P 500. We test on SPDR S&P 500 Trust ETF which has the ticker code SPY.
All in all, we do four different backtests:
- Strategy 1: When the close of SPY crosses BELOW the N-day moving average, we buy SPY at the close. We sell when SPY’s closes ABOVE the same average. We use CAGR as the performance metric.
- Strategy 2: Opposite, when the close of SPY crosses ABOVE the N-day moving average, we buy SPY at the close. We sell when SPY’s closes BELOW the same average. We use CAGR as the performance metric.
- Strategy 3: When the close of SPY crosses BELOW the N-day moving average, we sell after N-days. We use average gain per trade in percent to evaluate performance, not CAGR.
- Strategy 4: When the close of SPY crosses ABOVE the N-day moving average, we sell after N-days. We use average gain per trade in percent to evaluate performance, not CAGR.
The results of the first two backtests look like this:
Strategy 1
Period |
5 |
10 |
25 |
50 |
100 |
200 |
CAR |
8.44 |
7.44 |
5.69 |
5.02 |
3.54 |
1.47 |
MDD |
-30.75 |
-38.01 |
-38.68 |
-39.82 |
-50.96 |
-52.18 |
Strategy 2
Period |
5 |
10 |
25 |
50 |
100 |
200 |
CAR |
1.17 |
2.15 |
3.83 |
4.47 |
5.91 |
7.97 |
MDD |
-66.96 |
-56.19 |
-48.77 |
-40.44 |
-49.84 |
-28.86 |
The results from the backtests are pretty revealing: in the short run, the stock market shows tendencies to mean-reversion. In the long run, it is better to use trend-following strategies.
Why do we reach that conclusion?
Because if we use a short moving average, the best strategy is to buy when stocks drop below the average and sell when it turns around and close above the moving average (buy on weakness and sell on strength). This can clearly be seen in the first test above for the 5-day moving average. The 5-day moving average returns a CAGR of 8.44%, which is almost as good as buy and hold even though the time spent in the market is substantially lower.
When we buy on strength and sell on weakness, in the second test in the table above, the best strategy is to use many days in the average. The longer the average is, the better. The 200-day moving average returns 7.97%, which is pretty decent. Worth noting is that the max drawdown is just half of buy and hold (28 vs 56%).
The results from backtests 3 and 4 look like this (the results are not CAGR, but average gains per trade):
Strategy 3
Period |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.29 |
0.38 |
1.08 |
2.14 |
4 |
8.62 |
10 |
0.29 |
0.55 |
1.21 |
2.51 |
4.48 |
8.87 |
25 |
0.24 |
0.55 |
1.03 |
2.2 |
4.05 |
8.28 |
50 |
0.25 |
0.56 |
1.07 |
1.99 |
5.64 |
9.64 |
100 |
0.71 |
1.16 |
1.81 |
3.27 |
5.61 |
9.15 |
200 |
0.22 |
0.4 |
0.88 |
3.18 |
6.73 |
7.6 |
Strategy 4
Period |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.21 |
0.23 |
0.86 |
2.12 |
3.75 |
8.91 |
10 |
0.24 |
0.44 |
0.93 |
2.01 |
4.03 |
9.3 |
25 |
0.23 |
0.36 |
0.99 |
1.38 |
3.97 |
7.49 |
50 |
0.02 |
0.17 |
0.51 |
1.44 |
4.4 |
9.16 |
100 |
0.25 |
0.28 |
1.07 |
2.49 |
5.6 |
8.92 |
200 |
0.12 |
-0.34 |
0.24 |
2.54 |
6.11 |
10.28 |
As expected, the longer you are in the stock market, the better returns you get. This is because of the tailwind in the form of inflation and productivity gains.
However, be aware that this is just one method of testing a moving average. There are basically unlimited ways you can use a moving average and your imagination is probably the most restricting factor!
What is a geometric moving average (GMA)?
The geometric moving average is a type of moving average that calculates the geometric mean of the previous n-periods of the price time series. Unlike the simple moving average that uses the arithmetic mean, which means that it is calculated by adding the price time series’ value of the n previous price bars and then dividing the result by the lookback period, the geometric mean is calculated by multiplying the price time series’ n previous values and then taking the nth root product of the last result.
In other words, the geometric moving average uses the multiplication of the n-period price data instead of the addition method used in the simple moving average. The geometric mean is often used when working with returns and percentages. Its main advantage when working with returns is that it will allow you to compare different investments and strategies’ returns without knowing the initial amount invested.
How to calculate a geometric moving average
The geometric mean formula is given as follows:
GMA = [P_{1} x P_{2} x P_{3} …x P_{n}]^{1/n}
Where:
P_{1}, P_{2}, … P_{n} = price data for each period
n = the number of periods
Notice that the geometric mean formula multiplies the price data instead of adding them as it’s done in the arithmetic mean used in the simple moving average calculation.
Calculating the geometric moving average
From the formula above, the geometric average is calculated by taking the product of the data within the lookback period and raising it to the inverse of the length of the period.
To avoid any problems with negative percentages, we add one to each number. Next is to multiply all the numbers together and then raise their product to the power of the inverse of the count of the numbers in the lookback period. After that, we subtract one from the result.
So, when written in decimals, the formula would look like this:
[(1+P_{1}) x (1+P_{2}) … x (1+P_{n})]^{1/n} – 1
where:
P = price data
n = the length of the lookback period
Although the formula seems complex on paper, it’s not that difficult. Moreover, you don’t have to do the calculation manually, as your trading platform does the calculation and plots the indicator line once you attach the indicator to the chart.
Why use a geometric moving average?
The geometric moving average differs from the simple moving average in how it is calculated. Most importantly, the geometric mean takes into account the compounding that occurs from period to period, and as a result, investors usually consider it a more accurate measure of returns than the arithmetic mean.
As with the simple moving average, the GMA smooths the price data, reducing the noise, so that traders can make a better sense of what the price is doing. The indicator can help a trader to spot the direction of the trend, as well as identify when the trend is changing direction.
When a long-period GMA is used, it can show potential levels of support and resistance. Such levels may present some good trading opportunities.
How to use a geometric moving average
Not many trading platforms have a built-in geometric moving average indicator, so you may have to code one yourself or pay someone to do it for you. Once you have your custom GMA indicator installed, attach it to the chart. You will see the indicator line follow the price trend and swings.
Note that the period you set it would determine how smooth the indicator is and how closely it follows the price. The longer the period, the smoother it is, and the more slowly it reacts to price. So, if you want it to show the long-term trend only, set the lookback period at a high number.
How can you use a geometric moving average?
You can use the GMA just as you would use any other moving average indicator. You can use it to identify the direction of the trend, and in this case, it can also serve as a support level during an uptrend or a resistance level during a downtrend.
To get the best of the indicator, you can combine it with other indicators, such as oscillators, or price action analysis, to spot the right moment to enter a trade. For example, a bullish candlestick pattern, such as the hammer, forming around a rising long-period GMA after a pullback in an uptrend could signal the end of the pullback and a continuation of the uptrend.
You can also use two GMA indicators of different periods: one with a long-period setting (200) and another with a short period (say 30 or 50). A buy signal occurs when the short-period GMA crosses above the long-period GMA, while a sell signal occurs when the short-period GMA crosses below the long-period GMA.
Drawbacks with a geometric moving average
Just like other moving average indicators, the GMA has limitations. Some of them are as follows:
- It lags because it uses past price data.
- It is pretty useless when the price action is choppy or moving predominantly sideways. During such periods, it can give multiple false signals.
Relevant articles about moving averages strategies and backtests
Moving averages have been around in the trading markets for a long time. Most likely, moving average strategies were the start of the systematic and automated trading strategies developed in the 1970s, for example by Ed Seykota. We believe it’s safe to assume moving averages were a much better trading indicator before the 1990s due to the rise of the personal computer. The most low-hanging fruit has been “arbed away”.
That said, our backtests clearly show that you can develop profitable trading strategies based on moving averages but mainly based on short-term mean-reversion and longer trend-following. Furthermore, there exist many different moving averages and you can use a moving average differently/creatively, or you can combine moving averages with other parameters.
For your convenience, we have covered all moving averages with both detailed descriptions and backtests. This is our list:
- Moving average trading strategies
- Exponential moving average (backtest strategy)
- Hull moving average (backtest strategy)
- Linear-weighted moving average (backtest strategy)
- Adaptive moving average (backtest strategy)
- Smoothed moving average (backtest strategy)
- Variable moving average (backtest strategy)
- Weighted moving average (backtest strategy)
- Zero lag exponential moving average (backtest strategy)
- Volume weighted moving average (backtest strategy)
- Triple exponential moving average TEMA (backtest strategy)
- Variable Index Dynamic Average (backtest strategy)
- Triangular moving average (backtest strategy)
- Guppy multiple moving average (backtest strategy)
- McGinley Dynamic (backtest strategy)
- Fractal adaptive moving average FRAMA (backtest strategy)
- Fibonacci moving averages (backtest strategy)
- Double exponential moving average (backtest strategy)
- Moving average slope (backtest strategy)
We have also published relevant trading moving average strategies:
- The 200-day moving average strategy
- Trend-following system/strategy in gold (12-month moving average)
- Trend following strategies Treasuries
- Is Meb Faber’s momentum/trend-following strategy in gold, stocks, and bonds still working?
- Trend following strategies and systems explained (including strategies)
- Does trend following work? Why does it work?
- A simple trend-following system/strategy on the S&P 500 (By Meb Faber and Paul Tudor Jones)
- Conclusions about trend-following the S&P 500
- Why arithmetic and geometric averages differ in trading and investing
FAQ Geometric moving average
Let’s end the article with a few frequently asked questions:
What is a geometric moving average strategy?
A geometric moving average strategy is a technical analysis tool used by traders to analyze the trend of an asset. It uses a series of data points, such as closing prices, to calculate a moving average.
The geometric moving average strategy is different from other moving average strategies in that it incorporates the geometric mean of the data points to arrive at the average.
We have covered the difference between arithmetic and logarithmic means earlier:
- Why Arithmetic And Geometric Averages Differ In Trading And Investing
- Linear Vs. Logarithmic Charts And Scale – What Is Log Scale Chart (What Is The Difference?)
How does a geometric moving average strategy work?
The geometric moving average strategy calculates the geometric mean of the data points in a given period. The geometric mean is calculated by multiplying each data point and then taking the nth root, where n is the number of data points used. This mean is then used to calculate the moving average which is then used to identify the trend of the asset.
What are the advantages of using a geometric moving average strategy?
A geometric moving average strategy is more effective than other moving average strategies when it comes to identifying the trend of an asset. It is more accurate in isolating the trend because it takes into account the geometric mean of the data points. This ensures that the moving average is more reflective of the asset’s true value.
But keep in mind that any moving average is just a derivative of the price action and always lags.
What are the drawbacks of using a geometric moving average strategy?
The main drawback of using a geometric moving average strategy is that it is more difficult to interpret than other moving average strategies. It is also more difficult to calculate because it requires the calculation of the geometric mean. This means that it is more time-consuming to execute than other moving average strategies.
What types of assets are best suited for a geometric moving average strategy?
Geometric moving average strategies are best suited for assets that exhibit long-term trends. This is because the geometric mean captures the true value of the asset over a longer period of time. This means that it is more effective at identifying long-term trends in assets such as stocks, bonds, and commodities.
Does the geometric moving average work?
At the end of the day, the only thing that matters is to make money. And to find out if you have a strategy that has a positive expectancy, you need to backtest.
Geometric moving average – takeaways
Our takeaway from the backtests is that geometric moving average strategies work well if you buy on weakness (a close below the moving average) when you use a short number of days. Opposite, it’s best to buy on strength (a close above the moving average) when you use a long moving average.