◆ New — Strategy Validator, Code Fixer & Prop Compliance Checker are live. Try one free →
Home / Indicators / McGinley Dynamic
Moving Averages indicator

McGinley Dynamic

A moving average with a self-adjusting denominator that speeds up in fast markets and slows down in quiet ones.

Illustrative diagram — not live market data.

What it is

The McGinley Dynamic is a moving-average variant published by John R. McGinley, a market technician and former editor of the Market Technicians Association's journal, in the 1990s. It was designed to address a real weakness of fixed-length averages: a 14-period EMA responds at the same fixed speed whether the market is crawling or gapping, so it hugs price too tightly in quiet conditions and falls badly behind in fast ones. The Dynamic replaces the fixed smoothing constant with a denominator that scales with the ratio of price to the indicator's own previous value raised to the fourth power — so when price pulls away quickly, the divisor shrinks and the line accelerates to catch up; when price is near the line, the divisor grows and the line slows down. It is often described as tracking price 'better', and it does typically stay closer in fast moves than an EMA of the same nominal length — but it remains a lagging summary of past prices, not a forecast, and the 'avoids whipsaws' claim attached to it is overstated. Educational content only, not financial advice; all trading involves risk of loss.

How it works

The recursive formula is: MD = MD₁ + (Price − MD₁) / (k × N × (Price / MD₁)⁴), where MD₁ is the previous bar's value, N is the length, and k is a constant McGinley set at 0.6 to make the Dynamic track slightly faster than an EMA of the same N. The mechanism lives in the denominator. When price equals the previous MD, the ratio is 1 and the update behaves like a smoothing filter of effective length k·N. When price races above the line, (Price/MD₁)⁴ becomes large, the denominator grows — wait, note the direction: for upward moves the fourth-power ratio exceeds 1, enlarging the divisor and damping the update, while for downward moves the ratio drops below 1, shrinking the divisor so the line falls faster. This asymmetry is deliberate: McGinley designed it to follow sell-offs more quickly than rallies. Real implementations must also guard edge cases the textbook formula ignores: the first bar has no previous MD (seed it with price), and a zero or negative previous value would make the ratio undefined or the fourth power misbehave — a genuine concern on synthetic series like spreads, though not on ordinary price data. Correct code handles both explicitly rather than assuming clean input.

How traders read it

Common settings

The usual published form uses a length of 14 with the constant k = 0.6, applied to the close; some platforms expose only the length and hard-code k. Lengths in the 10–20 range behave broadly like their EMA counterparts but adapt to speed. Because the formula is recursive, values near the start of the chart depend on the seed and take time to converge — treat early-history readings as warm-up.

Strengths

Pitfalls to watch

Pine v6 example

//@version=6
indicator("McGinley Dynamic", overlay = true)

length  = input.int(14, "Length", minval = 1)
kFactor = input.float(0.6, "K Constant", minval = 0.1, step = 0.1)
src     = input.source(close, "Source")

// Recursive value, seeded with price on the first bar
float md = na
prevMd  = nz(md[1], src)

// Guard the ratio against zero/invalid previous values
ratio4  = prevMd != 0 ? math.pow(src / prevMd, 4) : 1.0
divisor = math.max(kFactor * length * ratio4, 1e-10)

md := prevMd + (src - prevMd) / divisor

plot(md, "McGinley Dynamic", color = color.orange, linewidth = 2)
plot(ta.ema(src, length), "EMA (reference)", color = color.gray)

Pro tip: Overlay the Dynamic on an EMA of the same length and study two regimes separately: a strong directional move (the Dynamic visibly closes the gap faster, especially downward) and a tight range (both lines whipsaw — the Dynamic's advantage largely disappears). That two-regime test tells you honestly what the adaptive denominator buys and what it doesn't. Educational context only, not financial advice; adaptive smoothing describes past speed, predicts nothing, and all trading carries risk of loss.

Built an indicator from this? Run it through the Validator to catch look-ahead bias and repainting, or convert a strategy to Pine Script.

Educational only — not financial advice, not a recommendation to trade. No indicator is predictive; trading involves substantial risk of loss.

Catch the bug that compiles.Run auditGet Pro