Loading…

Adaptive Laguerre Filter

The original Laguerre filter takes gamma as a fixed input chosen by the user - one setting has to serve both trending and choppy market conditions. Ehlers' adaptive version removes that trade-off by recomputing the damping factor every bar instead. At each bar, the filter measures how far the current price has strayed from the filter's own previous output (the absolute deviation), then rescales that deviation against the highest and lowest deviation seen over a trailing window (default 12 bars): alpha = (deviation - lowest) / (highest - lowest). A deviation near the top of its recent range produces alpha near 1 - the filter reacts fast, tracking a genuine trend move with little lag. A deviation near the bottom of its recent range produces alpha near 0 - the filter smooths heavily, since the price action looks like noise rather than a real move. That adaptive alpha is then used in place of a fixed gamma inside the identical L0-L3 cascade published for the original Laguerre filter. The result self-adjusts its own speed without the user having to pick a single gamma that compromises between trending and ranging behaviour. Notes and limitations - Needs InpAdaptivePeriod + 5 bars of history before it produces a value. - When the highest and lowest deviation in the window are equal (a perfectly flat, no-deviation stretch), alpha falls back to 0 for that bar rather than dividing by zero. - Recomputed from bar zero on every call, since both the deviation history and the L0-L3 recursion carry state forward from the previous bar - it cannot be correctly resumed from an arbitrary mid-history point. - This is a smoothing overlay only; it does not generate trade signals or alerts.

Indicator · MT5 · v1.0 · Free

About Adaptive Laguerre Filter

Adaptive Laguerre Filter is an indicator for MetaTrader 5. It has 1 setting, such as Adaptive period. MQL source code included.

Files in the download: AdaptiveLaguerreFilter.ex5, AdaptiveLaguerreFilter.mq5, AdaptiveLaguerreFilter.txt.

Settings

SettingDefaultWhat it does
Adaptive period12Lookback window used to rescale the deviation into alpha 0..1

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Trend · MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria