A channel built from the highest high and lowest low over a chosen lookback period.
Donchian Channels, developed by trader Richard Donchian, are a three-line indicator plotted directly on the price chart. The upper band is the highest high over the last N bars, the lower band is the lowest low over the last N bars, and the middle line is the average of those two values. A common default is 20 periods. The channel simply visualizes the recent trading range and where price sits within it. It is educational information about past price extremes, not a prediction of future movement, and no indicator can remove the risk of loss in trading.
For each bar, the indicator looks back over a fixed number of bars (for example 20) and records two things: the single highest high and the single lowest low within that window. Those become the upper and lower bands. The middle line is just the midpoint between them. As new bars form, the window slides forward, so the bands step up or down only when a new extreme high or low enters or leaves the lookback. Because the bands track recent highs and lows rather than a smoothed average, they tend to stay flat during quiet ranges and shift quickly when price prints a new extreme.
A lookback period of 20 bars is the most widely cited default. Shorter settings such as 10 react faster to recent extremes; longer settings such as 50 or 55 (a length associated with classic trend-following systems) produce a wider, slower channel. Applied to the price chart as an overlay.
//@version=6
indicator("Donchian Channels", overlay = true)
length = input.int(20, "Lookback", minval = 1)
upper = ta.highest(high, length)
lower = ta.lowest(low, length)
basis = math.avg(upper, lower)
u = plot(upper, "Upper", color = color.teal)
l = plot(lower, "Lower", color = color.teal)
plot(basis, "Basis", color = color.gray)
fill(u, l, color = color.new(color.teal, 90))Pro tip: Watch the lookback length deliberately. Because each band is set by the single most extreme bar in the window, a wick or one-off spike can pin a band for the full lookback. Comparing the channel against the actual candles helps you tell a genuine range shift from a one-bar outlier. This is for education only and is not advice to act on.
Educational only — not financial advice, not a recommendation to trade. No indicator is predictive; trading involves substantial risk of loss.