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 Donchian Regime Breakout is a trend-following channel breakout system that pairs the classic Donchian channel (an N-bar highest-high / lowest-low band) with a regime filter built on an exponential moving average (EMA). A Donchian channel simply plots the highest high and lowest low over a set number of past bars; price closing beyond that band is the traditional signal that a new trend leg may be starting. This strategy keeps that time-tested trigger but wraps it in extra logic designed to filter out the low-quality breakouts that tend to fail.
The reason for the filter is well known to anyone who has studied breakout trading. A raw Donchian breakout fires constantly inside sideways, range-bound markets, and the majority of those breaks reverse almost immediately. This system is designed for trending market conditions, and it attempts to trade only in the direction of the dominant trend. It does this by requiring a long-period EMA to be sloping the correct way and price to be sitting on the correct side of that EMA before any breakout is considered valid.
As a learning tool, the Donchian Regime Breakout is well suited to intermediate traders who want to understand how a directional filter, a volatility-scaled entry gate, and an adaptive trailing stop can be combined into a single rules-based framework. It is a strategy analysis exercise, not a shortcut — the value here is in seeing how each component is meant to reduce false signals and manage open risk.
How It Works
The strategy evaluates its rules once per completed bar, not on every tick. When a new bar closes, it recalculates its indicators and checks the following conditions in order.
Entry conditions — the strategy signals a trade only when all three align:
- Regime filter (the core edge). A long trend EMA must slope in the trade's favour, and price must sit on the matching side of it. For a long, the EMA must be rising (its current value above its value
EmaSlopeLookbackbars ago) and the signal bar must close above the EMA. For a short, the EMA must be falling and the close must be below it. Flat or counter-trend conditions are simply ignored. - Breakout trigger. The just-completed bar must close beyond the Donchian channel formed from the N bars behind it (the signal bar itself is excluded from the channel calculation). A close-based break is used deliberately, because it is more robust than an intrabar touch that can be caused by a single volatile wick.
- Conviction gate. The close must clear the channel edge by at least
ConvictionAtrMult × ATR. The ATR (Average True Range) measures recent volatility, so this gate automatically scales with market conditions — marginal pokes just over the band are skipped, while genuine thrusts qualify.
When a rising-EMA regime coincides with a conviction-confirmed break above the upper channel, the strategy signals a long. When a falling-EMA regime coincides with a conviction-confirmed break below the lower channel, it signals a short.
Exit and risk logic:
- Initial stop-loss. On entry, a fixed stop is placed at
SlAtrMult × ATRaway from the fill price — below entry for longs, above entry for shorts. - Take-profit. A target is placed at
TpAtrMult × ATRfrom entry in the trade's direction. With the defaults (stop 2× ATR, target 4× ATR), the intended reward-to-risk ratio is roughly 2:1. - Chandelier trailing stop. If
TrailAtrMultis greater than zero, an ATR-based trailing stop pulls the stop toward price byTrailAtrMult × ATRas the trade moves favourably. Crucially, it only ever tightens — it locks in an open runner's progress and never widens the risk. - One position per magic number. The strategy holds a single position at a time and does not pyramid or add to winners.

Strategy Parameters
| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
| ChannelPeriod | 20 | 10 | 60 | Number of bars behind the signal bar used to build the Donchian breakout channel. |
| TrendEmaPeriod | 100 | 40 | 200 | Length of the trend EMA used for the regime (direction) filter. |
| EmaSlopeLookback | 5 | 1 | 30 | How many bars back the EMA slope is measured over to judge trend direction. |
| AtrPeriod | 14 | 7 | 40 | ATR window used for the conviction gate, stop, target and trailing distance. |
| ConvictionAtrMult | 0.10 | 0.0 | 1.0 | The close must clear the channel edge by this multiple of ATR to count as a real break. |
| SlAtrMult | 2.0 | 0.5 | 5.0 | Initial stop-loss distance, expressed as this multiple of ATR from entry. |
| TpAtrMult | 4.0 | 1.0 | 10.0 | Take-profit distance, expressed as this multiple of ATR from entry. |
| TrailAtrMult | 2.5 | 0.0 | 6.0 | Chandelier trailing-stop distance in ATR multiples (0 disables trailing). |
| Lots | 0.10 | 0.01 | 1.0 | Fixed position size in lots for each trade. |

Recommended Chart Settings
The Donchian Regime Breakout is single-timeframe: every calculation uses whatever chart timeframe you attach it to, so the same code adapts to your chosen timeframe at run time. Breakout systems with a long trend filter (a 100-period EMA by default) are commonly studied on higher timeframes such as H1, H4, or D1, where breakouts tend to be cleaner and trending phases last longer. Major, liquid instruments — for example widely-traded forex pairs like EUR/USD — are a sensible starting point because their tighter spreads reduce the cost of ATR-scaled stops.
Because the strategy relies on a persistent trend to work as intended, its behaviour will vary substantially across different symbols and market conditions. Always test any timeframe and symbol combination thoroughly on historical data and on a demo account before drawing conclusions.
How to Install on MetaTrader 5
- Download the
DonchianRegimeBreakout.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
Like every strategy, the Donchian Regime Breakout has clear strengths and equally clear limitations that you should understand before committing capital.
Strengths of the approach:
- The regime filter is designed to keep the system out of the choppy, sideways markets where raw Donchian breakouts historically suffer the most, since it demands both EMA slope and price-side agreement.
- The conviction gate is volatility-aware: because it is measured in ATR, the required breakout distance expands in fast markets and contracts in quiet ones, rather than using a fixed pip value.
- ATR-based stops and targets keep risk proportional to current volatility, and the chandelier trail is structured to protect open profit without ever loosening the stop.
Known limitations and where it may underperform:
- Whipsaws in ranges. No filter is perfect. During prolonged sideways markets the EMA can flatten and flip, producing breakouts that reverse and repeatedly hit the stop. This is the most common failure mode of any breakout method.
- Lag from the trend filter. A 100-period EMA reacts slowly. The strategy may enter well after a trend has begun and may keep signalling in the old direction just as a trend is ending.
- Gaps and slippage. ATR stops assume orderly price action. News spikes, weekend gaps, or thin liquidity can fill stops far from their intended level.
- Single position, no pyramiding. Holding only one trade at a time is simpler and lower-risk, but it also means the system cannot compound a strong trend by scaling in.
The honest takeaway is that this is a structured, rules-based framework for studying trend-following breakouts — not a set-and-forget solution. Its performance is highly dependent on whether the chosen market is genuinely trending.
Risk Management Tips
Sound risk management matters more than any single entry rule. As you study this strategy, keep these general principles in mind:
- Risk a small, fixed fraction per trade. Many educational sources suggest never risking more than 1–2% of account equity on any single position. The default fixed
Lotsvalue does not automatically scale to your account size, so calculate whether the ATR stop distance keeps you within that limit. - Understand your drawdown tolerance. Trend-following systems can endure long strings of small losses between winning trends. Know how much peak-to-trough decline you are willing to accept before you begin.
- Always start on a demo account. Run the EA on a demo or simulated account across varied market conditions until you fully understand its behaviour, frequency of trades, and typical open risk.
- Account for costs. Spreads, commissions, and slippage all erode results, especially on lower timeframes where trades are more frequent.
- Never trade money you cannot afford to lose. Leverage magnifies both gains and losses.
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: DonchianRegimeBreakout.ex5 (0 downloads)
- Source Code: DonchianRegimeBreakout.mq5 (0 downloads)
- Documentation: DonchianRegimeBreakout.pdf (0 downloads)