Ehlers Empirical Mode Decomposition
This is a practical engineering reconstruction of the idea behind John Ehlers' Empirical Mode Decomposition article, built from his own published filter primitives rather than a byte-for-byte reproduction of one specific EasyLanguage listing. The pipeline is: a 2-pole highpass filter removes the slow trend component from price (the same construction used in the Roofing Filter submission), a 2-pole bandpass resonator then isolates whatever cyclical energy remains near a chosen period, and a peak/valley tracker follows that bandpass output's envelope. The midpoint of Peak and Valley is plotted as Mean - a trend estimate rebuilt from the cycle's own centre rather than a lagging average of price. The width of the envelope, Peak minus Valley, is the cycle's measured amplitude, and that width is what decides the mode label in the corner of the chart. The logic behind the label is straightforward once the filter chain is understood: a bandpass filter has almost nothing to show at its tuned period when price is moving through it monotonically rather than oscillating around it - a trend, by definition, has little energy at any one cycle length. So when the current envelope width falls below a threshold fraction of its own recent average, that collapse is read as "the market has stopped cycling and started trending." This threshold (InpTrendFraction) and the envelope decay rate are reasonable, clearly documented rules built on that same amplitude-collapse logic Ehlers describes - they are not a fixed constant lifted verbatim from the original article, and are exposed as inputs precisely because reasonable traders can disagree on where the line sits. Notes and limitations - Peak and Valley are confirmed with a genuine one-bar delay: a bar is only recognised as a local extreme once the bar after it has closed, so nothing here looks ahead, but the envelope is always one bar behind the actual turn. - The TREND/CYCLE label is a rule-based classification built on envelope amplitude, not a rigorous statistical test - treat it as a supporting read alongside the chart, not as a standalone signal. - Two cascaded recursive filters mean roughly InpModeLookback plus a few cycle periods of history are needed before the mode reading and the average width settle; earlier bars are seeded flat. - This decomposes price into a trend-ish midline and a cyclical envelope around it; it does not forecast where either goes next.
Indicator · MT4 · v1.0 · Free
About Ehlers Empirical Mode Decomposition
Ehlers Empirical Mode Decomposition is an indicator for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 7 settings, such as High pass period, Cycle period and Bandwidth. MQL source code included.
Files in the download: EhlersEmpiricalModeDecomposition.ex4, EhlersEmpiricalModeDecomposition.mq4, EhlersEmpiricalModeDecomposition.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| High pass period | 20 | Highpass cutoff period in bars (detrend stage) |
| Cycle period | 20 | Bandpass tuned period in bars |
| Bandwidth | 0.3 | Bandpass bandwidth fraction (Ehlers' Delta) |
| Envelope decay | 0.991 | Per-bar decay applied to Peak/Valley between confirmed extremes |
| Trend fraction | 0.4 | Width below this fraction of its own average marks "trend" mode |
| Mode lookback | 50 | EMA length for the envelope-width average used by the mode test |
| Alerts | true | Alert once per closed bar when trend/cycle mode changes |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 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: Channels & Envelopes · Trend · Alerts · MT4 Indicator · MQL4 Source Code