Ehlers Roofing Filter
Most oscillators are built directly on closing price, which is a mistake Ehlers spent several books explaining: price contains a slow trend component that swamps short-cycle detail, and a fast tick-noise component that aliases into false signal once you difference or average it. The roofing filter removes both, deliberately, in two stages. First a 2-pole highpass filter with a long cutoff (48 bars by default) removes everything slower than that - the trend and the "spectral dilation" that comes from using raw price. Second, a 2-pole SuperSmoother - a Butterworth-style low pass with steep rolloff - removes everything faster than its own short cutoff (10 bars by default), which is the tick noise. What remains is a roughly zero-mean, band-limited version of price with the frequency content that actually matters for cycle and momentum work. This is a preprocessing filter, not a finished trading signal by itself - Ehlers' own follow-on work (stochastic RSI, cycle indicators) runs on top of this output rather than on raw price. It is published standalone here because the filter chain is useful on its own as a clean momentum read and because getting the two pole coefficients right, in the right order, is where casual ports usually drift from the original. Notes and limitations - Both filter stages are recursive (each bar depends on the two before it), so the first few bars after InpHighPassPeriod is changed are a brief warm-up rather than a true reading; they are seeded at zero rather than left blank. - This filters price, it does not predict it. A clean zero-mean oscillator still needs a trading rule on top - crossing zero, diverging from price, or feeding a further indicator - none of which this file adds by design. - Because it is a true lag-minimising recursive filter, not a lookahead smoother, it never repaints: every value shown for a closed bar is final. - Very short InpLowPassPeriod values relative to the chart's own bar noise can leave meaningful high-frequency content in the output; the 10 bar default is a reasonable starting point, not a universal constant.
Indicator · MT4 · v1.0 · Free
About Ehlers Roofing Filter
Ehlers Roofing Filter is an indicator for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 3 settings, such as High pass period, Low pass period and Alerts. MQL source code included.
Files in the download: EhlersRoofingFilter.ex4, EhlersRoofingFilter.mq4, EhlersRoofingFilter.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| High pass period | 48 | Highpass cutoff period in bars (removes slow trend) |
| Low pass period | 10 | SuperSmoother cutoff period in bars (removes tick noise) |
| Alerts | true | Alert once per closed bar on a zero-line cross |
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: Oscillator · Buy/Sell Arrows · Trend · HFT · Alerts · MT4 Indicator · MQL4 Source Code