Skip to content

AI analysis

Donchian channel crypto breakouts: freeze the prior window

A genuine closing breakout disappears when its candle is added to the reference channel too soon. Reconstruct the window and the observation before testing fills.

Two segmented ivory rails end before a lime sphere, with a detached ivory block farther right on a black background.
Illustration for ai analysis; examples in this article are educational.

A Donchian channel crypto breakout compares a price observation with the highest high or lowest low of a defined number of prior bars. Exclude the candidate bar from that reference window, then state whether the rule requires an intrabar breach, a closing-price break or a preplaced order trigger. Those observations occur at different times and cannot share an assumed fill price.

The useful question is not simply whether a candle appears outside a band. It is which bars built the band, when that boundary became available and what observation counted as a break. A small indexing error can suppress every signal or quietly change the strategy being tested.

Define the channel before defining the breakout

For a window of N bars, a Donchian channel takes the highest high as its upper boundary and the lowest low as its lower boundary. Its middle line is halfway between those two extrema. It is not an average of all closing prices. TradingView's Donchian calculation describes this construction.

For the candidate bar t, define the reference explicitly:

  • Upper reference: maximum high across bars t−N through t−1.
  • Lower reference: minimum low across bars t−N through t−1.
  • Midpoint: (upper reference + lower reference) / 2.

Then a strict closing breakout above the prior range means close[t] > upper reference. A strict downside closing breakout means close[t] < lower reference. Neither rule establishes that continuing in that direction will be profitable.

An indicator may legitimately display a channel that includes the current bar. The strategy must then use its previous completed value for this particular breakout rule. TA-Lib's Donchian notes distinguish the current-bar calculation from the prior-band comparison. Check the implementation rather than assuming a plotted offset changes the underlying signal data.

Reconstruct one candidate candle

All prices below are hypothetical quote-currency units for one invented crypto instrument on one venue. The three-bar period is deliberately short so the arithmetic is inspectable; it is not a setting recommendation. Every row is a completed bar with valid OHLC values.

BarOpenHighLowCloseRole when evaluating D
A981009599Prior observation
B9910497102Prior observation
C10210296100Prior observation
D100106100105Candidate
E105106102104Next candidate
F104107103106Later candidate

Before D, the upper reference is max(100, 104, 102) = 104; the lower is min(95, 97, 96) = 95. The midpoint is 99.5. D's final close of 105 exceeds 104, so D satisfies the stated closing breakout rule.

If the implementation updates the three-bar channel with D first, its window becomes B, C and D. The upper boundary becomes 106. The test changes to 105 > 106, which is false. This is more than one missed example: for valid ordinary OHLC bars, the candidate close cannot exceed its own high, and its high cannot exceed a maximum that includes it. A strict close-above-current-upper-band condition therefore cannot trigger.

Changing > to >= does not repair the intended rule. It turns some bars closing exactly at the current rolling maximum into signals. That is a different condition and can include repeated equal highs.

CandidatePrior three barsUpper referenceCandidate highCandidate closeHigh strictly exceeds reference?Close strictly exceeds reference?
DA, B, C104106105YesYes
EB, C, D106106104NoNo
FC, D, E106107106YesNo

F separates a wick breach from a closing breakout. It also tests equality: a close exactly at 106 does not satisfy a strict close above 106. Preserve these rows as a fixture when comparing two implementations.

Choose the observation clock

An intrabar rule can react while a candle is forming. A closing rule must wait for its final close. A preplaced stop order can become eligible during the candle because its instruction existed beforehand. They are three different experiments even when they reference the same prior upper boundary.

With F, an intrabar observer sees a trade above 106 at some point. The closing observer eventually sees 106 and records no strict closing breakout. The OHLC row does not say when the high occurred, whether an application received it promptly or whether an order filled.

For a close-based strategy, do not assign a purchase at the prior upper boundary merely because the completed candle exceeded it. That price was observed before the decision existed. TradingView's broker emulator, under its default bar-close calculation and order settings, generally fills newly generated orders on the next available tick, represented by the following bar's open. Other settings change that model; this is simulator behavior, not a promise about exchange fills. TradingView's order creation and execution documentation

The broader backtest evidence guide covers execution assumptions. The Donchian-specific requirement is to preserve the boundary, observation and order eligibility as separate records.

Audit window edges and repeated signals

Require N valid prior bars before evaluating the first candidate. Decide what happens if a venue candle is absent, duplicated or unfinished. Silently using fewer observations changes the rule. The look-ahead bias audit explains how to inspect when data became usable.

A rolling maximum can fall when an old extreme leaves the window. Suppose an older high of 110 expires, the remaining prior highs have a maximum of 105 and the candidate closes at 106. It qualifies against 105 while remaining below the older 110 extreme. That is consistent with the chosen window. Preserve its membership to distinguish a new local breakout from a break of a more distant high.

Also define whether consecutive qualifying bars may add exposure to an existing position. Several rising candles can each close above their own prior reference. Testing the condition on every bar can therefore differ from allowing only the first transition from false to true. Neither is automatically permission for several orders. Record position state, re-entry conditions and duplicate-event handling alongside the signal.

Keep filters separate from the reference

Trend-strength or volume context can become additional hypotheses, but neither repairs an incorrect window. ADX trend strength measures a different property from whether price exceeded a prior extreme. If an ADX gate is added, preserve its period, availability and threshold separately and count that as a changed rule.

Likewise, anchored volume profile organizes observed volume into price bins. A Donchian upper band contains no information about how much volume traded there. Do not describe the channel's extreme as a high-volume area without separate evidence from the relevant venue and data.

Use an explicit position-sizing calculation after defining entry and invalidation assumptions. Channel width is a price-range measurement; it does not determine an account's acceptable loss or guarantee that an exit will execute.

A worksheet for reviewing the saved rule

FieldWhat a reviewable definition contains
InstrumentVenue, symbol, spot or derivative, price source
WindowN valid prior bars, interval, timestamp convention
CandidateExcluded from the extrema calculation
ObservationIntrabar high/low, finalized close, or order trigger
ComparisonStrict or inclusive inequality and any price buffer
EventEvery qualifying bar, first crossing, or flat-position entry only
ExecutionEarliest submission time, order type and fill assumptions
Failure policyMissing bars, unfinished candles and repeated events

Method and limits

This AI-assisted article uses primary indicator and simulator documentation plus an original six-bar arithmetic fixture and review worksheet. The example demonstrates signal definitions, not expected returns. No historical market series, KLINEO Donchian control or live strategy was tested. A correctly timed breakout can still reverse immediately; costs, gaps and execution failures remain separate risks to evaluate under a declared backtest methodology.

Keep the context with the example.

Each worked example is illustrative, with its sources and assumptions in the article. Read our editorial standards for authorship, verification and corrections.