Choose the correct Donchian window for a breakout test

Choose the correct Donchian window for a breakout test

Specify the boundary before the test

Define the upper boundary as the highest high of the previous three completed bars. Define the event as today's close strictly above that boundary. This wording fixes the window, observation time and comparison operator. Some indicators plot a channel including the current bar; that drawing can be valid for a different use.

Run a four-bar example

Let the previous three highs be 100, 102 and 101. Today's high is 105 and its close is 104. The prior upper boundary is 102, so the close exceeds it by 2. A channel including today shows 105 instead. The same close cannot exceed that value since a valid candle closes at or below its own high.

104 > max(100, 102, 101)

Separate a touch from a break

Change today's close to 102 while keeping its high at 105. The intrabar high breached the prior channel; the close only touched it. A greater-than-or-equal comparison would include this bar, while a strict close breakout would exclude it. Choose which event you intend before counting examples.

Check indexing with one saved timestamp

On a newly opened bar, the just-completed candle is at shift 1. To test that closed candle against the previous three highs, take shifts 2 through 4. Log both the time of the candidate and the times of the highs used. Repeat on the lower boundary with lows and a strict less-than comparison.

Sources and further reading

Back to top

MQLume Bespoke

Built around your ambition.

Explore bespoke services →

Have something more specific in mind?

Ask us about advanced custom development. Share your requirements through private support or email; we will discuss the scope and quote separately.

100% committed to following up on your delivery and support requests.

Free downloads. Real source files.

FREE

Lizard [MQLume]

MQL5 / MT5Version v2.21

Free editable gold breakout project with six independently selectable cores, session filters and flexible position sizing.

US$149.00FREE
FREE

Scraper Gold [MQLume]

MQL5 / MT5Version v3.80

Free editable source with compiled EX5: four gold breakout engines with independent profiles, sizing, direction and exits.

US$95.00FREE
FREE

EA Black Dragon [MQLume]

MQL5 / MT5Version v13.0

Trend-based entries with optional grid additions, side controls and virtual exits.

US$30.00FREE
FREE

Hamster Scalping [MQLume]

MQL5 / MT5Version v21.0

RSI entries with two ATR filters, configurable sessions and optional grid management.

US$30.00FREE
MQLume

More to explore. A community to share it with.

Stay close to MQLume, wherever you like to learn.

YouTube

See our EAs in action. Explore backtests, walkthroughs and practical guides.

Watch on YouTube

Telegram

Meet other EA users, share ideas and keep up with what’s new.

Join the community Follow official updates

Cart

One personal-use licence per project. Each project can be added once.

Your cart is waiting for its first passenger.

Choose an EA or source edition to get started.

Continue shopping