stratester.com

Price · condition block

Breakout (N-candle high or low)

The breakout block fires when the close clears the range of the previous N candles: above their highest high, or below their lowest low. It is the classic channel (Donchian) breakout used by trend followers.

How the engine evaluates it

For high, the engine finds the highest high of the N candles before the current one (the current candle is not included) and fires when the current close is above it.

For low, it finds the lowest low of the previous N candles and fires when the close is below it.

The block needs N earlier candles. It can stay true on several candles in a row while price keeps setting new highs, because each new close is compared with a window that moves forward.

Formula
high: close > max(high of the previous N candles)
low:  close < min(low of the previous N candles)

Botscript syntax

In the Lab you pick this block from the Price group and fill in its fields. In the code view the same condition is written like this:

breakout high 48
breakout low 20

Settings

SettingValuesDefaultNotes
Sidehigh, lowhighBreak above the range or below it.
Lookback1 – 1,000 candles48The width of the range the close must clear.
Timeframethe run's candles, or 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d, 1wthe run's candlesOptional. At least the run's candle size and a whole multiple of it.

On a higher timeframe

Add a timeframe at the end to read Breakout from bigger candles than the run uses, for example breakout high 20 on 1d. The engine builds those candles from the run's own candles (UTC, weeks start on Monday) and evaluates the block only on candles that have closed, so there is no look-ahead. Lengths and lookbacks count the bigger candles.

Breakout is a state on a higher timeframe: the result from the last completed bigger candle holds on every run candle until the next one closes.

The timeframe must be at least the run's candle size and a whole multiple of it; otherwise the run stops with an error and is not charged. Multi-timeframe conditions covers the details, including warm-up.

How traders use it

  • Trend entries: breakout high 55 is close to the famous Turtle Traders' 55-day breakout on daily candles.
  • Trailing exits: breakout low 20 with sell 100% exits when price makes a 20-candle low.
  • Combine with ADX (adx(14) > 25) to skip breakouts in flat markets.

Example bot

botscript
bot "Channel Breakout"

when breakout high 55
then buy 100%

when breakout low 20
then sell 100%
  • Buys when the close beats the highest high of the previous 55 candles.
  • Sells when the close drops below the lowest low of the previous 20 candles.

Pitfalls

  • Breakouts fail often in ranging markets; most of the profit in breakout systems comes from a few long trends.
  • The signal uses the close. Intrabar spikes beyond the range do not trigger it.

Breakout: frequently asked questions

Is the current candle part of the range?

No. The range is the N candles before the current one, so a close above it is a genuine new high.

Is this the same as a Donchian Channel breakout?

Yes. The upper Donchian line is the highest high of N candles and the lower line is the lowest low; this block fires when the close crosses beyond them.

Why did it fire several candles in a row?

In a strong trend each new close can clear the highest high of the candles before it. Add cooldown or rely on the one-position-at-a-time default to avoid repeated entries.

What lookback should I use?

Common choices are 20 and 55 on daily candles. Shorter lookbacks trade more and catch more false breaks.

Simulated results are hypothetical. They include only the fee and slippage you set on the bot, not every real-world cost or market condition, and past performance does not guarantee future results. Nothing here is financial advice.