McGinley Dynamic – Trading Strategy Backtest (Does it work?)
Last Updated on August 22, 2022 by Oddmund Groette
McGinley Dynamic Indicator strategy backtest
Different types of moving averages are used in technical analysis. However, the McGinley Dynamic indicator stands out for its attempt to solve a problem inherent in moving averages that use fixed time lengths. It’s a type of moving average that is designed to improve existing moving averages. But do you know what it is? Can we make profitable McGinley Dynamic strategies in the markets?
Yes, McGinley Dynamic Indicator (moving average) strategies do work. Our backtests show that a McGinley Indicator (moving average) can be used profitably for both mean-reversion and trend-following strategies on stocks.
The McGinley Dynamic indicator is a moving average that was invented by John R. McGinley, a renowned market technician, to track the market. It is a better indicator than most moving average indicators as it improves upon moving average lines by adjusting for shifts in market speed.
Table of contents:
McGinley Dynamic Indicator strategy backtest and best settings
Before we go on to explain what the McGinley Dynamic Indicator 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 McGinley Dynamic Indicator strategy work? Can you make money by using McGinley Dynamic Indicator 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 |
7.82 |
6.31 |
5.4 |
4.02 |
2.83 |
1.14 |
MDD |
-30.16 |
-35.17 |
-37.02 |
-42.89 |
-49.18 |
-52.94 |
Strategy 2
Period |
5 |
10 |
25 |
50 |
100 |
200 |
CAR |
1.78 |
3.22 |
4.12 |
5.5 |
6.72 |
8.5 |
MDD |
-65.74 |
-50.81 |
-49.23 |
-47.2 |
-44.96 |
-40.62 |
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 closes 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 7.82%, 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.89%, which is pretty decent. Worth noting is that the max drawdown is just half of buy and hold (28 vs 56%).
However, most of the drawdowns are bigger than most of the other moving averages, for example, the simple moving average.
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.26 |
0.47 |
1.13 |
2.14 |
3.72 |
8.88 |
10 |
0.13 |
0.34 |
1.1 |
2.44 |
3.88 |
8.3 |
25 |
0.29 |
0.58 |
1.13 |
1.96 |
4.66 |
9.32 |
50 |
0.38 |
0.46 |
1.16 |
2.6 |
4.15 |
9.42 |
100 |
0.54 |
0.79 |
1.38 |
2.84 |
5.02 |
9.3 |
200 |
0.4 |
0.45 |
0.45 |
2.57 |
3.92 |
8.57 |
Strategy 4
Period |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.27 |
0.27 |
0.85 |
2.45 |
4.28 |
9.09 |
10 |
0.14 |
0.16 |
0.98 |
2.2 |
4.2 |
8.37 |
25 |
0.19 |
0.27 |
0.63 |
1.41 |
3.73 |
7.99 |
50 |
0.24 |
0.14 |
0.93 |
1.08 |
3.67 |
8.92 |
100 |
0.23 |
-0.05 |
0.7 |
1.33 |
3.92 |
8.52 |
200 |
-0.14 |
0.23 |
-0.07 |
0.76 |
2.73 |
6.67 |
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 we have tested just four strategies of the moving average. There are basically unlimited ways you can use a moving average and your imagination is probably the most restricting factor!
What is the McGinley Dynamic indicator?
The McGinley Dynamic indicator is a type of moving average built to improve traditional moving averages’ functionalities. It solves the problem of varying market speeds by automatically adjusting its speed concerning the prevailing market conditions — it speeds up when the market is trending and slows down when the market is ranging. Imagine the McGinley Dynamic Indicator as a moving average with a filter for smoothening price data to avoid whipsaws.
The McGinley Dynamic Indicator reduces price separations and volatilities to more accurately report price action. It was created in the 1990s to address the tendency to apply moving averages inappropriately. It also helps to account for the gap that often exists between prices and moving average lines.
Traditional moving averages, such as the exponential, simple, or weighted moving averages, are designed with fixed time spans that make it difficult to account for the changes in market speed. Therefore, the McGinley Dynamic indicator is developed to solve this problem by moving simultaneously with the market.
John R. McGinley invented the McGinley Dynamic indicator after studying the various technical analysis strategies for over forty years. The McGinley Dynamic indicator was first introduced in the Journal of Technical Analysis in 1997.
How to calculate the McGinley Dynamic indicator
The formula for calculating the McGinley Dynamic indicator is given as follows:
McGinley Dynamic Indicator (MDi)= MDi-1 + [Price – MDi-1 / N × (Price / MDi-1)⁴ ]
where:
MDi-1 = MD value of the preceding period
Price=Security’s current price
N=number of periods
The constant N indicates how closely the Dynamic keeps a tab on the index or stock. For example, if you are using a 20-day moving average, use the N as half the value of the moving average. The 4th power is an adjustment factor to the calculation; it rises whenever the difference between the Dynamic and the current data increases. This means that the formula allows for both acceleration and deceleration while focusing on the security’s price movement.
Why use the McGinley Dynamic indicator?
The McGinley Dynamic indicator is used to get a more accurate reflection of price action without complete dependence on fixed periods. It also helps to reduce varying market speeds, which is one of the major limitations of traditional moving averages.
Since the McGinley Dynamic indicator stays aligned to any market, whether trending or ranging market, traders use it to make trading decisions and correctly time their entrance and exit points. Also, the McGinley Dynamic Indicator can automatically adjust itself as per the speed of the market.
How to use the McGinley Dynamic indicator
Like traditional moving averages, most trading platforms have a built-in McGinley Dynamic indicator. It is relatively easy to set up the indicator.
If you’re using TradingView, for example, you simply type in the indicator’s name in the search tab and select it. Then adjust the value of “N” in the formula. The “N” defines the number of periods. For instance, if you want to replicate a 20-day MA, you should set the length for the McGinley Dynamic to 10. Usually, the default value for the “N” is set at 14 periods on most platforms.
If the indicator is not on the trading platform you are using, you can code a custom indicator yourself or pay someone to code it for you.
How can you use the McGinley Dynamic indicator?
Traders can use the McGinley Dynamic indicator in various ways:
It can be used by traders to monitor trends on a price chart and better decide when to buy and sell. For example, suppose the McGinley Dynamic indicator is in an area of price support. A trader could wait until the price bounces off and the candlestick moves above the indicator line to buy. The stop-loss order should be placed below the indicator line. If the candlestick pattern changes from a bullish candle to a bearish candle, the trader should exit the position.
On the other hand, when the McGinley Dynamic indicator is in a resistance area, a trader can choose to sell a security when the price bounces off resistance, and the candle moves below the indicator line. In this case, the stop loss would be placed above the line.
Apart from the fact that you can also use the McGinley Dynamic indicator with support and resistance levels to decide whether to take a long or short position on a security, you can combine the indicator with volatility and volume indicators to confirm price trends. Pairing it with an oscillator indicator, such as the relative strength index (RSI), can indicate a trend’s direction, as well as individual price swings. For example, an RSI higher than 50 indicates the price of a security is on an uptrend, while the 70 and 30 levels help you to identify overbought and oversold markets.
Drawbacks with the McGinley Dynamic indicator
The McGinley Dynamic indicator also has some limitations. You need to be very cautious when using the indicator: it moves faster when markets fall than when they rise. And it is even more difficult to use when the market is ranging.
In addition, since the McGinley Dynamic indicator was designed as a smoothing mechanism, it should not be the only technical indicator you use for your trading decisions. Moreover, while it reduces the issue of lag, it does not remove it completely.
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)
- Geometric moving average GMA (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
McGinley Dynamic Indicator – takeaways
Our takeaway from the backtests is that the McGinley Dynamic Indicator works well if you buy on weakness (a close below the moving average) and sell on strength (a close above 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 longer moving average.