Donchian Channel Breakouts: Define the Signal Without Look-Ahead
Learn how Donchian bands use recent highs and lows, why a breakout must be compared with the prior completed band, and how bar timing, fills, exits, and testing change the rule
In this guideA Donchian channel marks recent extremes, not a forecast
Short summary
A Donchian channel marks the highest high and lowest low in a chosen rolling window. A breakout rule needs one extra decision: does today’s price cross the boundary made by earlier bars, or a band that has already moved to include today? Compare the signal with the prior completed band, define whether a wick or close counts, and model an executable fill separately.
A Donchian channel marks recent extremes, not a forecast
For a lookback of N bars, the upper band is the highest high in the window, the lower band is the lowest low, and the basis is their midpoint: (upper + lower) ÷ 2. The basis is not a moving average of closes. The bands describe the range of observed extremes under one data and timeframe convention; they do not identify fair value, guarantee support or resistance, or predict that a price move will continue. TradingView documents the three lines and uses 20 periods as its default length, which is a platform setting rather than a universal recommendation {source:tradingViewDonchianChannels}.
The shape can change when a new extreme enters the window or an old extreme leaves it. A flat band therefore does not mean the market stopped trading; it means the rolling extreme did not change. If a five-minute chart uses 20 bars, the window spans a very different clock interval from 20 daily bars. Before calling a line “the 20-day high,” check that the chart is actually using daily bars and the intended session.
Offset the reference window before calling a bar a breakout
A common plotted upper band at time t is U_t = max(H_t, H_{t-1}, …, H_{t-N+1}); the lower band is L_t = min(L_t, L_{t-1}, …, L_{t-N+1}). Those bands include the current bar. If the rule says “the close finishes above today’s upper band,” it cannot fire: C_t ≤ H_t ≤ U_t. Likewise, a close cannot finish below a lower band that already includes today’s low. TA-Lib’s Donchian documentation states that its window includes the current bar and places the breakout comparison against the previous band, U_{t-1} or L_{t-1} {source:taLibDonchianFunction}.
For a close-confirmed upper breakout, test C_t > U_{t-1}; for a lower breakout, test C_t < L_{t-1}. If the event is intrabar, compare the current high or low with the same prior completed band. TradingView exposes a separate visual offset for moving plotted channels, but a display offset does not by itself define the data series used by an order rule {source:tradingViewDonchianChannels}. Write the index explicitly in code, spreadsheet logic, or a paper rule. A one-bar error can turn a valid past-only test into an impossible condition or a look-ahead comparison.
Specify whether a wick or a close creates the event
“Breakout” is not one unique event. A strict high-through rule might trigger when H_t > U_{t-1}; a close rule might require C_t > U_{t-1}; an order rule might rest a buy stop at U_{t-1} and trigger on a venue-defined trade or quote. A bar that trades above the level and closes back below passes the first test but fails the second. Equality also matters: > excludes a touch exactly at the level, while ≥ includes it. On a tick-based market, say how the boundary is rounded and what happens when the old high repeats.
A close-based signal is only known when that bar is complete. If the backtest enters at the same close that established the signal, it assumes the decision and fill happened at a price that was not final until the bar ended. A next-bar order, an intrabar stop, and a close auction order have different information and execution rules. With only OHLC bars, the high and low do not reveal which came first, so do not invent an intrabar path when both a trigger and an exit level lie inside the same bar.

Use a hypothetical 20-bar break to check the timing
Suppose the highest high of the previous 20 completed bars is 105.20 and the lowest low is 98.60. The next bar opens at 104.90, reaches 105.55, falls to 104.65, and closes at 105.40. A high-through rule records an upper break because 105.55 > 105.20. A close rule records one only after the bar finishes because 105.40 > 105.20. If the high had been 105.35 but the close 105.10, the intrabar rule would trigger while the close rule would not.
Once the current bar enters a current-inclusive 20-bar plot, its upper band becomes 105.55. Its close of 105.40 is then below that updated line. That does not erase the prior-band breakout; it shows why the comparison window must be named. If a close-confirmed signal is followed by a next-session open at 105.90, an illustrative close-to-open difference is 0.50 per unit before spread, commission, slippage, and contract value. These invented prices demonstrate timing only; they are not a quote, fill promise, or strategy result.
Freeze lookback, timeframe, and price conventions
A lookback of 20 means 20 observations in the selected series, not automatically 20 calendar days. Decide whether the bars use regular hours or an extended session, which exchange timezone defines a daily bar, and how missing or holiday periods are treated. For futures, the front contract changes at a roll. A back-adjusted continuous series can move old highs and lows by the adjustment amount, while orders trade in the listed contract at its unadjusted prices. Calculate the signal series and execution series deliberately, then document how they map.
Stock splits and other corporate-action adjustments can similarly change historical extremes. A higher-timeframe band displayed on a lower-timeframe chart also has an update rule: a value from an unfinished daily bar can change before the daily close. TradingView describes a “wait for timeframe closes” option for this reason. Use only the last completed higher-timeframe bar if that is what the live rule would know {source:tradingViewDonchianChannels}. Freeze data vendor, symbol mapping, session, adjustment, lookback, comparison price, and warm-up window before evaluating outcomes.
Keep the entry channel separate from exits and risk limits
An entry band does not specify how a position closes. A system might enter on a 20-bar breakout and exit on a shorter opposite channel; another might use a price invalidation, a volatility stop, a time exit, or no new position after a separate filter. These are different systems. A shorter exit channel can respond sooner but also produce more reversals; a longer exit may stay with a move longer while leaving more open risk. The entry length alone tells you neither the initial loss distance nor the position size.
Measure a separate stop distance in tradable ticks, apply the contract’s tick value, include plausible costs, and set quantity from a stated risk budget. Don’t assume the opposite Donchian band is a protective stop: it may be far away and it moves as new bars arrive. For the futures-specific link between stop distance and contract exposure, see the ATR stop-distance guide. Record whether an exit channel is checked intrabar or at a completed close, and keep any gap-through handling explicit.
Test a fully specified rule, not a line on a chart
A useful test records the signal window, prior-bar reference, strict or inclusive comparison, high/low/close input, session, entry timing, exit rule, stop, sizing, and order type. Include commissions, bid–ask spread, slippage, gaps, and realistic order activation. Compare the rule with an appropriate benchmark and report drawdown, exposure, turnover, and trade count alongside return. A plotted band can look identical while two implementations differ by one bar or by the session used to build daily highs.
Historical studies of trading-range-break rules do not validate every Donchian configuration. Brock, Lakonishok, and LeBaron tested specific moving-average and trading-range-break rules on Dow Jones data from 1897 through 1986; that sample and those definitions are not a forecast for today’s market or proof for a 20-bar channel with different costs {source:brockLakonishokLeBaronTradingRangeBreaks}. Sullivan, Timmermann, and White later examined technical-rule performance while adjusting for the universe of tested rules and data-snooping risk {source:sullivanTimmermannWhiteDataSnooping}. Keep a chronological holdout or use walk-forward validation, and account for parameter search rather than reporting only the best length; the Deflated Sharpe guide covers that selection problem.
Treat the signal level and the execution price as separate facts
A breakout level is a condition, not a guaranteed fill. If a market opens beyond the prior band, an order may execute at a different price from the threshold. In the United States, a stock stop order becomes a market order after its stop price is reached; the SEC’s Investor.gov bulletin says the stop price is not a guaranteed execution price and that a stop-limit order can remain unfilled {source:secStopOrderExecutionLimits}. Those are stock-order explanations, not a complete description of futures, foreign-exchange, or crypto-venue rules. Check the applicable broker and venue terms.
Keep separate timestamps and prices for the band calculation, signal, order submission, trigger, and fill. A stop-limit can constrain price but adds non-execution risk; a stop-market can prioritize exit while accepting slippage. Neither choice makes an intrabar channel break a close-confirmed one. For a futures gap example, see the session-break gap-risk guide. Evaluate the complete order path before calling a historical level a tradable breakout.
Common questions
Q1Is 20 the best Donchian lookback?
No universal lookback is established by the indicator definition. Twenty is a common platform default. The useful period depends on the market, bar construction, rule, costs, and the testing process; tuning it on one history can overfit.
Q2Why does my close never cross the plotted upper band?
The plotted band may include the current bar’s high. A close is not greater than a band that already contains that high. For a past-only breakout test, compare today’s close with the band from the previous completed bar.
Q3Does a breakout guarantee that an order fills at the channel price?
No. A signal, order trigger, and execution are different events. A gap, available liquidity, broker trigger convention, and order type can change the fill or leave a limit order unfilled.
Sources and further reading
Report an issue
We’ll prepare an email with this article link. Mark receives the report only after you send it
Quick check
Read the guide? Check yourself with 3 questions
Question 01
A platform plots the highest high including the current bar. Which comparison can define a close-confirmed upper breakout?
Choose an answer to see the explanation
Options glossary
Clear definitions of essential option terms, from calls, puts, and option chains to IV, Greeks, open interest, and max pain
Browse the options glossary