Breakout Alert Indicator: A 20-Bar Donchian Channel

Written by Dominic Walsh · Published · Last updated

The breakout alert indicator uses one of the oldest rules in trading. Take the highest high and the lowest low of the last twenty bars. When a close pushes past either edge, mark it. Nothing else takes part.

This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from GBPUSD M15.

Platforms MT4 (.ex4) + MT5 (.ex5)
Chart window Main price chart
Plots 4: Donchian High, Donchian Low, Breakout BUY, Breakout SELL
Alerts popup, push notification, email, sound
Inputs 8

What the Breakout Alert Indicator draws on the chart

A deep pink `Donchian High` line traces the upper edge.

A dodger blue `Donchian Low` line traces the lower one.

`Breakout BUY` uses arrow 233 and `Breakout SELL` uses 234.

Marks sit `ArrowOffsetPts` `8.0` points from the candle.

  • Donchian High: line, deep pink, width 2
  • Donchian Low: line, dodger blue, width 2
  • Breakout BUY: arrow, lime, width 2, arrow code 233
  • Breakout SELL: arrow, red, width 2, arrow code 234
Breakout alert indicator Donchian channel and break arrows on the GBPUSD M15 chart.
Breakout alert indicator Donchian channel and break arrows on the GBPUSD M15 chart.

How the Breakout Alert Indicator calculates its values

The channel excludes the current bar

Both edges scan `LookbackBars` `20` bars starting one bar back. That matters. Including the current bar would make a breakout impossible, because the bar would always be inside its own range.

A close decides the break

The current close has to finish above the prior high or below the prior low. Wicks do not count. So a spike that pierces the edge and retreats leaves nothing behind.

Nothing filters the result

No range check, no momentum test, no cooldown. Every qualifying close gets a mark. That keeps the tool honest about what it is, which is a plain channel break.

How to read the signals

The two lines step rather than curve, since they track extremes.

A flat channel means twenty bars produced no new extreme.

Breaks cluster at the start of a move and then stop as the channel widens.

The screenshot note picks GBPUSD M15 for clean channel breaks.

Alert channels in this build: popup, push notification, email and sound, one message per closed bar.

`EnableAlerts` is the main switch and arrives true beside `EnablePopup`. Turn on `EnablePushNotify` to reach a phone, `EnableEmail` for mail, or `EnableSound` to play `SoundFile`. A break reports once, on the bar that closed it.

Every Breakout Alert Indicator input

Core settings

Setting What it does Default
LookbackBars Donchian lookback (bars). Bars in the channel, starting one bar back, default `20`. 20

Display settings

Setting What it does Default
ArrowOffsetPts Arrow offset (points). Points between a mark and the candle, default `8.0`. 8.0

Alert settings

Setting What it does Default
EnableAlerts Main switch across the four routes, default `true`. on
EnablePopup Box inside the terminal, default `true`. on
EnablePushNotify Route to the phone, default `false`. off
EnableEmail Route to mail, default `false`. off
EnableSound Route to a clip, default `false`. off
SoundFile Which clip plays, default `”alert.wav”`. alert.wav
Breakout alert indicator inputs panel showing LookbackBars and ArrowOffsetPts.
Breakout alert indicator inputs panel showing LookbackBars and ArrowOffsetPts.

Settings that fit your chart

The screenshot note picks GBPUSD M15, where twenty bars covers five hours and breaks stay frequent. EURUSD H1 gives a slower version of the same thing. On daily bars a twenty-bar break is a month-scale event.

When the Breakout Alert Indicator fails

In a range price breaks both edges repeatedly, and each break fails.

The channel widens after a break, so the next one needs a much bigger move.

No filter ships at all, which is the trade this build makes for simplicity.

Copy the compiled Breakout Alert Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.

Background reading on the method behind the Breakout Alert Indicator: Typical price on Wikipedia, Cupandhandle at Investopedia.

Download the Breakout Alert Indicator for MT4 and MT5

The zip holds the compiled Breakout Alert Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.

Download this indicator free

Enter your email and the file is yours. You also get the full MT4 and MT5 library.

  • 1,380+ indicators
  • MT4 and MT5 files
  • No spam, unsubscribe any time

FAQ

Why does LookbackBars 20 start one bar back?

Because a channel including the current bar could never break. Shifting the window back one bar means the close meets history it did not help create, which is what makes a break mean anything.

What does the Donchian High line show?

The highest high of the previous twenty bars. It steps up when a new extreme enters the window and steps down when an old one drops out. Between those moments it holds perfectly flat.

Why do wicks not trigger a Breakout BUY?

The test reads the close only. A wick beyond the edge that pulls back is the failed break this rule skips, so ignoring it removes a large share of the false marks.

Should I raise LookbackBars for fewer marks?

Yes, that is the main lever here. A fifty-bar channel needs a much larger move to break, so marks become rare and each one describes a more significant event. Twenty is a scalping setting.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Breakout Alert Indicator as one input. Always backtest before trading live.

Category: this is part of our Signal and Forecast collection. Also, browse more Signal and Forecast for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.

External references

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

How we build, test and correct every tool: Editorial & Testing Policy. Trading carries risk; see the disclaimer.

Leave a Comment