Donchian Channels plot the highest high and lowest low of the last
period bars. The middle line is the average of the two. There's no
smoothing, no math - just rolling extremes.
Formula
upper = max(high, last N bars)
lower = min(low, last N bars)
middle = (upper + lower) / 2Params
period- lookback in bars. Required.
Output
Three columns:
{name}_upper{name}_middle{name}_lower
Usage
- Breakout entries: long on close above
upper(made by some earlier bar, not the current one). The classic Turtle System buys 20-day breakouts and exits on 10-day low. - Trailing stop: use Donchian lower (long) or Donchian upper (short) as an exit reference; see Stops & exits.
- Range detection: tight Donchian channels = sideways market.
Pitfalls
- Donchian leaks the current bar's high/low into the channel.
When you ask "is close > donchian_upper" you're asking "is close
max(high) over the window that includes the current bar." Use
crossoveror shift the indicator if you need a pure breakout-vs-previous-channel signal. - Whipsaws in chop: rolling extremes shift every bar, so a noisy market produces fake breakouts both directions.
