McGinley Dynamic
A fixed-period moving average lags more in a fast market and less in a slow one, which is exactly backwards from what a trader usually wants. McGinley's 1990s design fixes this by feeding the ratio of the current close to the average's own previous value back into the smoothing term, raised to the 4th power specifically so small deviations barely change the reaction speed while a real departure from the average speeds it up sharply. The result tracks price more closely in a trend and settles down in a range, without switching to a different period. Several "McGinley Dynamic" indicators published elsewhere are actually a plain EMA with the label changed, because the real recursive formula is mildly awkward to implement safely - the (Close/MD)^4 term can blow up on a large single-bar gap, sending the line briefly to an extreme value. This implementation uses the real formula and clamps only the denominator's magnitude (never the direction) when that happens, which is documented below rather than silently smoothed over. Notes and limitations - Seeded at the oldest available bar with that bar's raw close price, since the formula has no independently defined starting value; the seeding transient washes out within roughly InpPeriod bars, same as any other recursive average. - A single bar with an extreme price gap can make the (Close/MD)^4 term collapse toward zero; the denominator's magnitude is clamped to a small epsilon (sign preserved) in that case to avoid the line spiking to infinity, which understates the line's reaction to that one bar. This is a rare-case safeguard, not normal behaviour on ordinary data. - Like any recursive average, only the newest bars are recomputed on each tick - already-settled historical values are left untouched, so the line does not repaint further back than a genuine new bar close.
Indicator · MT5 · v1.0 · Free
About McGinley Dynamic
McGinley Dynamic is an indicator for MetaTrader 5. It has 1 setting, such as Period. MQL source code included.
Files in the download: McGinleyDynamic.ex5, McGinleyDynamic.mq5, McGinleyDynamic.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Period | 14 | McGinley constant N - larger values track slower, same role as an MA period |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: Moving Average · MT5 Indicator · MQL5 Source Code