Donchian Breakout EA MT5 — No Code

Channel breakout EA: classic 20-bar Donchian rule, how to code it in MQL5 with iHighest / iLowest, and a no-code Bollinger breakout alternative.

📖 6 min read

📝 1,001 words

🏷️ MQL5 and Expert Advisors

Share this article:

Donchian Channel Breakout EA for MT5 — No Code

Can I build a Donchian breakout EA for MT5 without coding?

Not in AlfaTactix today. Donchian Channel is not one of the indicators the MT5 Strategy Builder supports, so you cannot add it as a Step 3 condition. Two honest paths:

  1. Code it in MQL5 — the channel is just the highest high and lowest low of the last N closed bars (outline below).
  2. Build a no-code breakout EA with a supported indicator — Bollinger Bands breakout. It is a volatility band around a moving average, not a rolling high/low channel, so signals differ.

Disclosure: This is an educational guide, not financial advice. Backtest and Demo results do not guarantee live profits.

Related guides: Donchian Channel Indicator (academy) · Bollinger Breakout EA — No Code · Build EA Without Coding · Backtest in Strategy Tester · EA Strategy Library


What Is a Donchian Breakout EA?

A Donchian Channel breakout Expert Advisor automates one of the oldest channel breakout systems in trading:

SignalRule
Buy (long)Price breaks above the upper band (highest high over N periods)
Sell (short)Price breaks below the lower band (lowest low over N periods)

Donchian Channel plots upper, middle, and lower lines from rolling highs and lows. Turtle-style trend followers popularized 20-day (or 55-day) breakouts. In MQL5, the EA reads those rolling extremes itself; there is no built-in Donchian indicator function.

Why traders search for this: Clear rules for trend continuation after range expansion. This guide explains the rule, what it takes in MQL5, and the closest no-code path in AlfaTactix today.


Classic Donchian Settings and When It Works

SettingStarter valueNotes
Length20Classic “20-day” idea
Confirmation1 closed bar2 bars reduces false breaks
TimeframeH1 or D1H1 more signals; D1 cleaner trends
SymbolEURUSD, indices, commoditiesGold needs realistic spread in the tester

Works best: Strong trends after consolidation — London / New York liquidity for forex.

Struggles in: Sideways chop — breakouts reverse quickly. Mitigate with a session or spread filter, or require a minimum channel width.

For indicator background, see Donchian Channel Academy guide.


Donchian Channel Logic in MQL5

A hand-written EA computes the channel from the price series [1] on each new closed bar:

  1. Upper band = highest High of the last N closed bars before the signal bar (so the breakout bar is not part of its own channel).
  2. Lower band = lowest Low of the same bars. Middle = (upper + lower) / 2.
  3. Buy when the last closed bar's Close is above the upper band; Sell when it is below the lower band.
// OnTick, once per new bar
int hi = iHighest(_Symbol, PERIOD_H1, MODE_HIGH, 20, 2);
int lo = iLowest(_Symbol, PERIOD_H1, MODE_LOW, 20, 2);
double upper  = iHigh(_Symbol, PERIOD_H1, hi);
double lower  = iLow(_Symbol, PERIOD_H1, lo);
double close1 = iClose(_Symbol, PERIOD_H1, 1);
bool buy  = close1 > upper;
bool sell = close1 < lower;

A No-Code Breakout EA With Supported Indicators

The MT5 form supports the market's most-used indicators: RSI, SMA, EMA, WMA, MACD, Stochastic, Williams %R, CCI, Momentum, Bollinger Bands, ATR, Volume and OBV. For a breakout EA without code, use Bollinger Bands on Step 3, optional market session and spread filters on Step 4, and an ATR-based stop on Step 5. Walkthrough: Bollinger Band Breakout EA — No Code.

Difference to expect: Bollinger bands widen and narrow with volatility; a Donchian channel only moves when a new high or low prints. Compare both in the Strategy Tester before choosing.


Trader-Reported Themes (Forums)

In public threads on r/algotrading and r/Forex, traders often report these themes (not profit claims):

  • Donchian 20/55 breakouts are discussed as classic trend entries — many note long flat periods between signals.
  • False breakouts spike when volatility is low — some combine channel width or Bollinger Squeeze ideas.
  • Gold and indices need realistic spread in tester — see Strategy Tester vs Live.

Compile and Backtest

Compile your .mq5 (hand-written, or exported from Code Generator for the supported-indicator version) with F7 → Strategy Tester → Every tick → Demo before live. Wider stops suit channel breakouts on volatile symbols — see EA Risk Management.


Improvements: Filters and Risk

IssueFix
Too many false breaksWait for a 2nd closed bar outside the channel, or require a minimum channel width
Late entriesShorter Length (14) — more responsive, more noise
Range lossesTrade only London / New York; skip entries when the spread is above your limit


Tactix AI on this workflow

AlfaTactix includes Tactix AI: use Tactix Studio to describe your idea in plain language and draft timeframes, signals, filters, and risk into the same six-step Strategy Builder form — or open Tactix Guide on any step when you only need a field explained. Review every value, then export MQL5 or Pine Script from Code Generator (form-first — not untested prompt-to-code).

Next Steps

Before you trade it: Draw the 20-bar channel by hand on the chart you actually trade and check that your EA's first signals land on the same bars. If they don't, fix the logic first; a backtest won't fix wrong logic.

References: Donchian Channel (academy) · MQL5 timeseries access [1] · Strategy Tester [2].

Frequently Asked Questions

Not in AlfaTactix today. Donchian Channel is not one of the indicators the MT5 Strategy Builder supports. You can code it in MQL5 (the highest high and lowest low of the last N closed bars), or build a no-code breakout EA with a supported indicator such as Bollinger Bands, which is a different, volatility-based band.

Length 20 matches the classic 20-day channel idea on daily charts. On H1, test 20–55 in Strategy Tester on your symbol before live.

There is no built-in Donchian indicator function. An EA reads the highest high and lowest low of the last N closed bars with iHighest / iLowest (or CopyHigh / CopyLow) and compares the close with them.

This guide explains one public Donchian breakout template — not a full Turtle portfolio ruleset. Educational only; backtest and Demo on your broker.

No. Breakouts fail in choppy markets. This guide is educational: backtest, then Demo, then live with controlled risk.

References

  1. MetaQuotes, MQL5 Reference. Access to Timeseries and Indicator Data. https://www.mql5.com/en/docs/series
  2. MetaQuotes. MetaTrader 5 Built-in Trading Strategy Tester. https://www.metatrader5.com/en/automated-trading/strategy-tester

AlfaTactix is a no-code strategy builder for MetaTrader 5 (MQL5) and TradingView (Pine Script) traders who design and manage rule-based strategies.

Trading involves substantial risk of loss. AlfaTactix generates code from the rules you define and does not provide financial advice. Past or backtested performance does not guarantee future results.

© 2026 AlfaTactix. All rights reserved.