Disclaimer: This article is for educational and informational purposes only. It does not constitute financial or investment advice. Trading forex and CFDs carries significant risk of loss. Past performance of any strategy — including backtests — does not guarantee future results. Never trade with money you cannot afford to lose.
What Is This Strategy?
Roofing Filter Cycle Reversion is a cycle mean-reversion strategy built around John Ehlers' Roofing Filter, a two-stage band-pass filter borrowed from digital signal processing (DSP). A mean-reversion approach assumes that when price swings too far from its recent center, it tends to snap back — and this strategy tries to time that snap-back at genuine cycle turning points rather than at arbitrary "overbought/oversold" readings.
The core idea is that any price series can be thought of as three layered components: a slow-moving trend (very low frequency), a tradable swing cycle (the medium frequency you actually want to fade), and noise (very high frequency, mostly spread and tick jitter). Classic oscillators that fade extremes often fail because the trend component leaks straight through them, so their "extremes" are really just trend artefacts. The Roofing Filter removes both ends of the spectrum — a high-pass filter strips out the trend and DC drift, and a super-smoother (a Butterworth-style low-pass) strips out the noise. What remains is a clean wave that genuinely oscillates around zero, so its peaks and troughs correspond to real cycle turns.
This EA is best understood as a learning tool for traders curious about DSP-based indicators, filter design, and disciplined mean-reversion logic. It suits students of technical analysis who want to see how band-pass filtering, z-score normalization, and ATR-based risk brackets fit together in a single, transparent system. It is not a shortcut and not a signal service — it is a worked example of one well-defined trading idea.
How It Works
The strategy processes one signal per newly closed bar on the chart's timeframe. Each closed bar is pushed through the recursive filter chain, and only then are entry rules evaluated. Here is the full pipeline in plain English:
- Stage 1 — High-pass filter (trend removal): A two-pole high-pass filter, tuned by the
HighPassPeriodcutoff, removes swings slower than the cutoff. Anything that slow is treated as trend/DC drift and discarded. - Stage 2 — Super-smoother (noise removal): The high-pass output feeds a two-pole super-smoother of length
SmoothPeriod. This low-pass step removes tick noise faster than the smoothing period, without the lag a plain moving average would add. The result is the roofing output — a near-zero-mean cycle wave. - Normalization (z-score): Because the wave's amplitude drifts with volatility, the strategy converts it into a z-score over a rolling window of
NormWindowbars. The z-score expresses "how many standard deviations from its own recent mean" the cycle currently sits, making the signal comparable across calm and volatile periods.
The strategy then fades the re-entry from an extreme — a confirmed turn, not a naked touch of the band — with fully symmetric long and short rules:
- Long entry — the strategy signals a buy when the z-scored cycle crosses back up through the
-Thresholdband (leaving the oversold zone) and the just-closed bar is bullish (its close is above its open). This aims to buy a swing low only after the cycle has begun turning up. - Short entry — the strategy signals a sell when the z-scored cycle crosses back down through the
+Thresholdband (leaving the overbought zone) and the just-closed bar is bearish (its close is below its open). This aims to sell a swing high only after the cycle has begun turning down.
Risk is handled with an ATR (Average True Range) bracket, where ATR is a volatility measure:
- Stop-loss: Placed
AtrStopMult × ATRaway from the entry price — below entry for longs, above entry for shorts. Wider volatility produces a wider stop automatically. - Take-profit: Set at a reward-to-risk multiple (
RewardRisk) of that ATR stop distance, so both targets scale with current market volatility. - One position per magic number: The strategy holds at most one open trade at a time; the ATR bracket manages every exit once a position is live.
- Spread guard: Entries are skipped whenever the current spread exceeds
MaxSpreadPoints, avoiding trades in thin or costly conditions.
Every calculation runs on a single timeframe — whichever chart the EA is attached to — so no higher- or lower-timeframe data is hardcoded.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| HighPassPeriod | 48 | 20 | 120 | High-pass cutoff in bars; swings slower than this are treated as trend and removed. |
| SmoothPeriod | 10 | 4 | 30 | Super-smoother period in bars; movement faster than this is treated as noise and removed. |
| NormWindow | 50 | 20 | 200 | Rolling window length used to z-score (normalize) the roofing output. |
| Threshold | 1.0 | 0.4 | 2.5 | Sigma band (in standard deviations) the cycle must exit to trigger a signal. |
| AtrPeriod | 14 | 5 | 30 | ATR lookback period used for the volatility-based stop. |
| AtrStopMult | 1.5 | 0.5 | 4.0 | Stop distance as a multiple of ATR, placed beyond the entry price. |
| RewardRisk | 1.2 | 0.6 | 3.0 | Take-profit distance as a reward-to-risk multiple of the ATR stop. |
| MaxSpreadPoints | 60 | 5 | 300 | Skip entries when the current spread (in points) is wider than this. |
| Lots | 0.10 | 0.01 | 1.0 | Trade volume in lots for each position. |
| Magic | 5150 | 0 | 9,999,999 | Unique magic number the EA uses to identify and manage its own trades. |

Recommended Chart Settings
Roofing Filter Cycle Reversion is designed for liquid, mean-reverting instruments on an intraday timeframe. Its natural home is a symbol such as EURUSD or XAUUSD, or a major index, on the M15 to H1 range. Liquidity matters here: the spread guard and ATR bracket assume reasonably tight, orderly conditions, which is where band-pass mean reversion tends to behave most predictably.
Because the timeframe is never hardcoded, the EA runs on whatever chart period you attach it to. That flexibility also means results will vary considerably across symbols, timeframes, and market regimes. A setting that produces clean cycle turns on one instrument may generate noisy or infrequent signals on another, so any change of symbol or timeframe should be studied on its own before use.
How to Install on MetaTrader 5
- Download the
RoofingFilterCycleReversion.ex5file from the link below. - Copy it to your MT5
MQL5\Expertsfolder. - Restart MetaTrader 5 or refresh the Navigator panel.
- Drag the EA onto a chart matching the recommended symbol and timeframe.
- Configure the input parameters and enable Algo Trading.
What to Consider Before Using This EA
Every trading approach involves trade-offs, and understanding them is part of learning to use any tool responsibly.
Strengths of this approach:
- The band-pass design directly addresses a common weakness of naive oscillators — trend leakage — by removing the trend component before measuring the cycle.
- Signals require a confirmed turn (a band re-entry plus a same-direction bar), which filters out many premature entries that a simple "touch the band" rule would take.
- Risk is defined before entry through the ATR stop and reward-to-risk take-profit, and the spread guard adds a basic cost filter.
Known limitations:
- Mean-reversion systems are, by nature, vulnerable to strong trends. If price breaks into a sustained directional move, the cycle can stay "extreme" while price keeps going — and a fade can be stopped out repeatedly. No filter removes trend risk entirely.
- The Roofing Filter is parameter-sensitive. The
HighPassPeriod,SmoothPeriod,NormWindow, andThresholdvalues interact, and poorly matched settings can either over-smooth (too few signals) or under-smooth (too much noise). This raises the risk of curve-fitting if parameters are tuned too aggressively to past data. - Recursive filters require a warm-up period; early bars produce no signals while the filter settles.
- Like all mean-reversion logic, it may underperform in low-volatility drift, news-driven gaps, or fast trending regimes, and its cycle assumptions may simply not hold on some instruments.
Treat this EA as a framework for studying how filtering and normalization change signal quality — not as a finished, hands-off system.
Risk Management Tips
Sound risk management matters more than any single indicator. Consider these general principles as you study the strategy:
- Risk only a small fraction per trade. A common guideline is to risk no more than 1–2% of account equity on any single position, and to size your
Lotsaccordingly rather than trading a fixed large volume. - Understand drawdown. Even a well-designed strategy will experience losing streaks. Know how large a peak-to-trough decline you can tolerate emotionally and financially before you commit real capital.
- Test on a demo account first. Run the EA on a demo account across different market conditions to observe how it behaves in trends, ranges, and volatile sessions before considering anything live.
- Match position size to volatility. Because the ATR stop widens in volatile conditions, a fixed lot size means a wider stop translates to a larger cash risk — factor that into your sizing.
- Never rely on backtests alone. Historical behavior is a study aid, not a forecast. Forward-test and review results regularly, and be prepared to stop the EA if conditions no longer suit its assumptions.
Risk Warning
Trading foreign exchange, CFDs, and other leveraged financial instruments involves substantial risk of loss and is not suitable for all investors. The strategies and tools discussed on this page are provided for educational purposes only and do not constitute financial advice, investment recommendations, or solicitation to trade. Always consult a qualified financial adviser before making trading decisions. Past backtest performance is not indicative of future results.
Downloads
- Expert Advisor: RoofingFilterCycleReversion.ex5 (34 downloads)
- Source Code: RoofingFilterCycleReversion.mq5 (32 downloads)
- Documentation: RoofingFilterCycleReversion.pdf (37 downloads)