McGinley Dynamic

The McGinley Dynamic (MD) of John McGinley (1997) is a moving average that adjusts its speed to the market: it speeds up when the price falls away below it and slows down when the price rises above it, so it hugs the price without the whipsaws of a fast average.

The formula for the McGinley Dynamic is as follows:

\[\text{MD} = \text{MD}_{t-1} + \frac{\text{Close} - \text{MD}_{t-1}}{k \cdot n \cdot \left(\frac{\text{Close}}{\text{MD}_{t-1}}\right)^{4}}\]

Where MD(t-1) is the Dynamic of the period before, n the number of periods and k a constant that scales the speed. The fourth power of the ratio of the close to the Dynamic makes it move faster as the price moves away from it, more so downwards than upwards. McGinley suggested \(k = 0.6\) to follow the price more closely.

A moving average smooths the price by averaging it over the last n periods, so that the trend shows through the noise of single periods. It is the oldest and most widely used trend indicator: the direction of the average shows the direction of the trend, the price above (below) it an uptrend (downtrend), and other indicators, from the MACD to the Bollinger Bands, are built on it. Every moving average trades smoothness against lag: the more periods it averages, the smoother it is and the later it turns after the price. The averages differ in how they weight the prices within the window and whether they adapt their speed to the market, each a different answer to that trade-off.

Also known as: MCGD, McGinley Dynamic Indicator.

In the Finance Toolkit this is get_moving_average with method="mcginley", the same function as Moving Average.

Example · ^GSPC · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_moving_average:

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["^GSPC"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.technicals.get_moving_average(method="mcginley", window=50)

Which returns:

References

  • Paper McGinley, J.R. (1997). “The McGinley Dynamic.” Journal of Technical Analysis (Market Technicians Association).
  • Library Referenced against TA-Lib’s MCGD (McGinley Dynamic)
  • Library Referenced against pandas-ta-classic’s mcgd (McGinley Dynamic)
Share