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?
The Vertical Horizontal Filter Breakout is a regime-gated channel breakout strategy built around the Vertical Horizontal Filter (VHF) — a trend-strength indicator — combined with a classic Donchian channel breakout. In plain terms, it is a trend-following system that tries to enter only when the market is actually trending, rather than chopping sideways. The VHF acts as a gatekeeper: it measures how "directional" recent price action has been and lets the strategy trade a breakout only when that reading is high and improving.
The core idea addresses a well-known weakness of breakout systems: most breakouts fail inside a ranging (choppy) market, where price pokes just past a support or resistance level and then snaps back. The VHF is designed to filter out exactly those conditions. It divides the net directional travel of price by the total distance price actually covered. When price marches steadily in one direction, those two numbers are close and the VHF reads high (trending). When price whipsaws back and forth, the total path is long relative to the net move, so the VHF reads low (choppy).
As a learning tool, this strategy is well suited to traders who want to understand how a filter can be layered on top of a raw entry signal to improve signal quality. It is designed with trending FX majors and index CFDs in mind, on intraday-to-swing timeframes. It is not a "set and forget" money machine — it is a structured, rules-based framework that demonstrates regime detection, ATR-based risk sizing, and trailing-stop trade management in one coherent package.
How It Works
The strategy runs on a single timeframe (whatever chart you attach it to) and evaluates signals only when a bar has fully closed, which avoids the "repainting" problem where a signal appears mid-bar and then disappears. Here is how the logic flows:
- Regime gate (the VHF filter): Before considering any trade, the strategy checks two things. First, the current VHF reading must be at or above the
VhfTrendThreshold. Second, the VHF must be rising — its current value must be greater than its valueVhfSlopeBarsbars ago. Only when both are true does the strategy treat the market as "trending and strengthening" and arm itself for entry. - Breakout entry (the Donchian channel): Once the regime gate is open, the strategy looks at the highest high and lowest low of the prior
ChannelPeriodbars (the bars before the just-closed signal bar). If the signal bar closes above the channel high plus an ATR-based buffer, the strategy signals a long. If it closes below the channel low minus that buffer, it signals a short. The buffer (BreakoutAtrBuffer× ATR) helps require a more convincing break rather than a marginal one. - ATR-based stop-loss: On entry, a stop-loss is placed at
SlAtrMult× ATR away from the entry price. ATR (Average True Range) measures recent volatility, so the stop automatically widens in fast markets and tightens in calm ones. - ATR-based take-profit: A take-profit target is set at
TpAtrMult× ATR from entry. With the defaults (stop 2× ATR, target 4× ATR), the target sits at roughly twice the stop distance, giving a positive reward-to-risk shape on winning trades. - Trailing stop (optional): If
TrailAtrMultis greater than zero, an ATR trailing stop follows the trade. It only ever tightens the stop in the trade's favor — it never loosens it — which is designed to let trend winners run while protecting open profit. - Reversal on regime flip: If a position is open and an opposite breakout closes, the strategy closes the existing position. Only one position per magic number is held at a time; the strategy waits for that position to clear before re-entering.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| VhfPeriod | 28 | 8 | 60 | Lookback length (in bars) for the Vertical Horizontal Filter calculation. |
| VhfTrendThreshold | 0.35 | 0.20 | 0.60 | Minimum VHF reading (0–1) required to treat the market as trending. Higher is stricter. |
| VhfSlopeBars | 3 | 1 | 10 | The VHF must be greater than its value this many bars ago (confirms a strengthening trend). |
| ChannelPeriod | 20 | 5 | 60 | Donchian channel lookback — how many bars before the signal bar define the breakout levels. |
| BreakoutAtrBuffer | 0.10 | 0.0 | 1.0 | Extra breakout confirmation distance beyond the channel, as a fraction of ATR. |
| AtrPeriod | 14 | 5 | 40 | Lookback for the ATR used in stops, targets, and trailing. |
| SlAtrMult | 2.0 | 0.5 | 5.0 | Stop-loss distance as a multiple of ATR. |
| TpAtrMult | 4.0 | 1.0 | 10.0 | Take-profit distance as a multiple of ATR. |
| TrailAtrMult | 2.5 | 0.0 | 6.0 | Trailing-stop distance as a multiple of ATR (set to 0 to disable trailing). |
| Lots | 0.10 | 0.01 | 1.0 | Order volume in lots per trade. |

Recommended Chart Settings
The Vertical Horizontal Filter Breakout was designed with trending FX majors (such as EUR/USD, GBP/USD, or USD/JPY) and major index CFDs in mind, on intraday-to-swing timeframes — think H1, H4, or D1. Because the system runs on whatever timeframe you attach it to, the same logic can be tested across a range of settings. Higher timeframes generally produce fewer but more deliberate signals, while lower timeframes produce more frequent signals with more noise.
As always, results will vary considerably across different symbols, timeframes, and market conditions. A configuration that behaves well on one instrument during a trending phase may behave very differently during a prolonged range. Treat the defaults as a starting point for study, not a finished configuration.
How to Install on MetaTrader 5
- Download the
VerticalHorizontalFilterBreakout.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
Strengths of this approach. The main design idea — refusing to trade breakouts unless a trend filter confirms directional momentum — directly targets the most common failure mode of raw breakout systems. The ATR-based stops and targets adapt to volatility automatically, and the optional trailing stop is structured to let winners extend while protecting gains. The rules are symmetric for long and short, and signals are evaluated only on closed bars, which reduces false signals from intrabar noise.
Known limitations. The VHF is a lagging indicator: by the time it confirms a strong, rising trend, part of the move may already be behind you. This is the inherent trade-off of any confirmation filter — it improves signal quality at the cost of entering later. Requiring the VHF to be both high and rising can also cause the strategy to sit out entirely during slow, grinding trends that never trigger the threshold.
Where it may underperform. Range-bound and mean-reverting markets are the natural enemy of any breakout system. Even with the filter, whipsaw conditions or sudden reversals right after a breakout can produce a string of losing trades. Sharp news-driven spikes can trigger a breakout entry just before price reverses. The strategy holds only one position at a time per symbol, so it does not pyramid or hedge, and it does nothing to avoid trading around scheduled high-impact news. None of these are flaws to hide — they are simply the conditions under which this style of system historically struggles, and understanding them is part of using it responsibly.
Risk Management Tips
Sound risk management matters far more than any single entry rule. Consider these general principles as you study this strategy:
- Position sizing: Size each trade so that a full stop-out costs only a small, predefined fraction of your account. A common educational guideline is to risk no more than 1–2% of account equity per trade.
- Test on a demo account first: Run the EA on a demo or paper account long enough to observe how it behaves across different market conditions before ever committing real capital.
- Understand drawdown: Every strategy experiences losing streaks. Review the maximum historical drawdown and ask yourself honestly whether you could tolerate that decline without abandoning the plan.
- Use appropriate leverage: Leverage amplifies both gains and losses. Lower leverage gives your account more room to survive adverse runs.
- Keep records and review: Log your trades and revisit the parameters periodically. Markets change, and a configuration that suited one regime may need adjustment in another.
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: VerticalHorizontalFilterBreakout.ex5 (39 downloads)
- Source Code: VerticalHorizontalFilterBreakout.mq5 (38 downloads)
- Documentation: VerticalHorizontalFilterBreakout.pdf (34 downloads)