Loading…

Ehlers Instantaneous Trendline

A moving average estimates the trend by averaging past bars, which means it can only ever confirm a turn after enough new bars have accumulated to outvote the old direction - that accumulation is exactly what causes its lag. Ehlers' Instantaneous Trendline instead comes from his Hilbert Transform work on measuring the market's dominant cycle: rather than averaging, it recursively estimates the smoothed midpoint of the current price cycle directly from a short window of recent closes and its own prior output, which is why it tracks price with markedly less delay than a moving average of comparable smoothness. Alongside the trendline itself, this file plots the Trigger line Ehlers defines as a two-bar-ahead linear projection of the trendline (2*ITrend - ITrend two bars back). Because Trigger runs ahead of ITrend by construction, a crossing between the two - Trigger through the trendline - flags a change of trend earlier than waiting for price itself to cross a moving average, which is the reading Ehlers describes in the book. The first several bars use Ehlers' own stated warm-up substitute, a simple three-bar weighted average, since the recursive formula has nothing valid to recurse from yet on brand-new history. Notes and limitations - This estimates trend direction, not the market's dominant cycle length - it is a smoothing/trend tool, distinct from Ehlers' cycle-period measurement indicators elsewhere in this catalogue. - The recursive filter can only see two bars of price history per step, so a sudden gap or a single extreme outlier bar can produce a visible kink before the filter settles back into a smooth line. - Never repaints: every plotted value for a closed bar is final, since nothing here looks ahead of the bar it is calculated on.

Indicator · MT5 · v1.0 · Free

About Ehlers Instantaneous Trendline

Ehlers Instantaneous Trendline is an indicator for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 2 settings, such as Alpha and Alerts. MQL source code included.

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

Settings

SettingDefaultWhat it does
Alpha0.07Filter alpha (Ehlers' book default; smaller = smoother/slower)
AlertstrueAlert once per closed bar when Trigger crosses the trendline

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: Moving Average · Trend · Alerts · MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria