MGDI (McGinley Dynamic Indicator) looks like a moving average but operates on a fundamentally different principle. Rather than using a fixed smoothing factor, it dynamically adjusts based on the ratio between price and the indicator's current value. The result is a filter that accelerates to catch breakouts while decelerating to avoid overshooting reversals—a behavior that fixed-alpha filters cannot achieve.
## Historical Context
Published by John McGinley in the *Market Technicians Association Journal* (1991), the Dynamic was created to be a "market tool" rather than just an indicator. McGinley observed that traditional moving averages have a fundamental flaw: their fixed period means they're either too slow in fast markets or too jittery in slow ones.
His insight was that the appropriate smoothing should depend on the relationship between price and the average itself. When price pulls far ahead, the average should accelerate. When price falls back toward the average, it should decelerate to avoid overshooting. The fourth-power ratio term creates this asymmetric, self-correcting behavior.
## Architecture & Physics
MGDI uses a nonlinear feedback mechanism that creates adaptive smoothing.
### 1. The Core Recursion
The update formula resembles an EMA but with a dynamic denominator:
The numerator $(P_t - \text{MGDI}_{t-1})$ is the standard "error" term—how far price is from the current estimate.
### 2. The Adaptive Denominator
The denominator $k \times N \times (P_t / \text{MGDI}_{t-1})^4$ is where the magic happens:
- **When $P_t > \text{MGDI}_{t-1}$**: The ratio exceeds 1, the fourth power amplifies it, the denominator grows, and the adjustment shrinks. This prevents overshooting during rallies.
- **When $P_t < \text{MGDI}_{t-1}$**: The ratio is below 1, the fourth power shrinks it further, the denominator shrinks, and the adjustment grows. This allows faster catch-up during declines.
1.**Not an EMA**: MGDI does not have a fixed alpha. Period comparisons with EMA are approximate at best. MGDI(14) does not equal EMA(14) in behavior or lag characteristics.
2.**Period Is Calibration**: The "Period" $N$ is a calibration constant, not a lookback window. MGDI(14) doesn't examine 14 bars of history—it's tuned to track instruments that typically move in 14-bar cycles.
3.**K Factor Sensitivity**: The constant $k=0.6$ is McGinley's recommended value. Reducing it (e.g., 0.4) makes the indicator more responsive but increases overshoot risk. Increasing it (e.g., 0.8) smooths further but adds lag.
4.**Division by Zero**: If $\text{MGDI}_{t-1} = 0$ (only possible with zero or negative prices), the formula fails. Implementation must guard against this edge case.
5.**Warmup Behavior**: The first few bars can exhibit unusual behavior until the indicator "locks on" to the price series. Allow 5-10 bars for stabilization.
6.**Ratio Extremes**: In volatile markets, the ratio $P_t / \text{MGDI}_{t-1}$ can reach extreme values. Some implementations clamp this ratio to prevent numerical instability.
7.**Bar Correction**: Use `isNew=false` for same-bar updates. The nonlinear formula means small price changes can produce disproportionate output changes during bar formation.