Fractal Adaptive Moving Average
Most adaptive moving averages scale their smoothing by a volatility ratio - faster when the recent range is wide, slower when it is narrow. FRAMA takes a different, geometric route: it measures the fractal dimension of the price path itself. A market chopping sideways traces a path almost as rough as random noise, with a fractal dimension near 2; a market trending cleanly traces a smoother, more line-like path, with a dimension near 1. Ehlers' formula gets there by comparing the range of the first half of the window, the range of the second half, and the range of the whole window - if the two halves' combined range is close to the full window's range, the path is relatively smooth (trending); if the combined range is much larger than the full window's range, the path is doubling back on itself (choppy). That dimension feeds an exponential decay constant (alpha = e^(-4.6*(D-1))), clamped to keep the smoothing constant in a sane 0.01-1.0 range, and the average is a standard exponential recursion from there. The result speeds up close to tracking price directly in a clean trend, and slows to a near- crawl in a chop - the same adaptivity goal as a variable-period MA, reached from a genuinely different measurement. Notes and limitations - InpPeriod must be even since it is split into two equal halves; the indicator refuses to initialise otherwise. - The fractal dimension is mathematically defined only within [1,2]; real price data can momentarily compute a value outside that range (a flat half-window range dividing into a logarithm, for instance), so the dimension is clamped to [1,2] before the alpha calculation, matching Ehlers' own published safeguard. - Like the alpha clamp itself ([0.01, 1.0]), this bounds worst-case behaviour rather than eliminating all noise in the dimension estimate - short InpPeriod values will still show some bar-to-bar jitter in how fast the line reacts. - Seeded at the oldest available bar with that bar's raw close; the seeding transient washes out over the first several dozen bars, same as any recursive average.
Indicator · MT5 · v1.0 · Free
About Fractal Adaptive Moving Average
Fractal Adaptive Moving Average is an indicator for MetaTrader 5. It has 1 setting, such as Period. MQL source code included.
Files in the download: FractalAdaptiveMa.ex5, FractalAdaptiveMa.mq5, FractalAdaptiveMa.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Period | 16 | Window (must be even) - split into two halves plus one full-window fractal-dimension pass |
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 · Fractals · Trend · MT5 Indicator · MQL5 Source Code