Ahrens Moving Average
Most simple recursive averages, an EMA included, feed a single current-price reading into the smoothing recursion at every step: MA[i] = MA[i-1] + (P[i] - MA[i-1]) / N. Ahrens' construction feeds the recursion a two-point average instead - the current price averaged with the price exactly N bars back: AhrMA[i] = AhrMA[i-1] + ( (P[i] + P[i-N]) / 2 - AhrMA[i-1] ) / N Averaging the current price with an older reference point before it ever reaches the recursion means the input driving the smoother is already partway towards where price has been over the last N bars, rather than being pinned entirely to the instantaneous last tick. The practical effect is a line that turns with a fast move sooner than a plain EMA of the same period, because the recursion is no longer being dragged bar by bar from a single current-price anchor - it is already being fed a value that reflects some of the recent range. The trade-off is the same one every low-lag construction makes: less lag comes at the cost of picking up more short-term noise than a plain EMA of the same nominal period would, since less smoothing inertia is being applied to price on the way in. Notes and limitations - Needs InpPeriod bars of history behind the oldest computable bar (to read the older entry point), so the line starts a little later in a short history than a plain EMA of the same period would. - Recursive: the very first computable bar has no prior AhrMA value to reference and is seeded with the entry-point average itself rather than a full recursive step. This affects only that one bar at the start of available history. - Does not repaint - each closed bar's value is fixed once computed.
Indicator · MT5 · v1.0 · Free
About Ahrens Moving Average
Ahrens Moving Average is an indicator for MetaTrader 5. It has 2 settings, such as Period and Applied price. MQL source code included.
Files in the download: AhrensMa.ex5, AhrensMa.mq5, AhrensMa.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Period | 14 | Smoothing period |
| Applied price | PRICE_CLOSE | Applied price |
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