How it works
Donchian Channels are the simplest possible volatility structure: draw a line at the highest high of the last N bars and another at the lowest low, and the space between them is where the market has traded. There is no smoothing, no average and no statistical assumption. The channel is a factual statement about the recent range, and by construction price can never close outside it without redefining it in the same instant.
That literalness is exactly why the tool endures. A break of the upper channel is not an interpretation, it is the definition of a new N-bar high, which makes it the cleanest possible encoding of a breakout rule. The famous Turtle experiment of the early 1980s built its entire entry logic on this: buy a twenty-day high, exit on a ten-day low, with position size governed by true range. The whole system fits in a paragraph and its performance came from discipline and sizing rather than from any subtlety in the signal.
The channel also carries volatility information even though nobody thinks of it that way. Its width is the realised range over the lookback, so a narrowing channel is a compression regime and a rapidly widening one is expansion. Where ATR averages the range of individual bars, Donchian measures the total ground covered end to end, which means a market that oscillates violently within a fixed band shows high ATR and a static Donchian width. That difference is genuinely informative: it separates a market that is moving from a market that is merely thrashing.
The main practical subtlety concerns whether the current bar is included in its own channel. Platforms usually include it, which makes the plotted upper line touch the current high whenever a new high prints, and that is fine for visual work but useless for a signal because the condition is true at the instant it becomes true. Systematic implementations shift the channel back one bar so the current bar is tested against the range of the prior N. Traders who skip this step and then backtest a breakout rule get results that cannot be reproduced in live trading.
Calculation
The arithmetic in words, in the order it happens.
The upper channel is the highest high over the last N bars and the lower channel is the lowest low over the same N bars, with N conventionally 20. The middle line is the simple average of the two, the midpoint of the range rather than an average of prices. No smoothing is applied at any stage. Most charting packages include the current bar in the lookback; systematic breakout rules normally evaluate the channel as of the previous bar so that the current bar can be tested against a range it did not help set.
Source
An AlgoBeamScript implementation of the formula above, written by us from the arithmetic so the code and the calculation agree line for line.
Runs unchanged on the platform and in the AlgoBeamTS runtime. The language reference is in the documentation.
Inputs
Defaults are the values most charting packages ship with. They are conventions, not optimal settings — the right length depends on your instrument and your holding period.
| Input | Default | What it changes |
|---|---|---|
| Length | 20 | Bars in the high and low lookback. Twenty is the classic breakout window. Shorter settings such as 10 produce frequent signals suitable for exits; 55 and above filters to major structural breaks and was the slower Turtle entry. |
| Offset | 0 | Shifts the channel in time. Setting it to one bar back is the standard fix that stops the current bar from defining the level it is being tested against. |
| Source for extremes | High / Low | Whether the channel tracks intrabar extremes or closing prices. Using closes produces a tighter channel and far fewer false breaks caused by single-tick spikes, at the cost of triggering later. |
How to read it
What practitioners take from the plot. Read these as descriptions of market state, not as entry signals.
- Close above the upper channel
- A new N-bar high. The canonical breakout entry, and the basis of most classical trend-following systems.
- Channel width contracting
- The market has covered less ground over the lookback than it recently did. A compression regime, and the condition breakout systems wait for.
- Price hugging the upper channel for many bars
- A persistent trend that keeps setting new highs. The lower channel becomes a natural trailing exit.
- Upper channel flat for weeks while price oscillates
- A defined range with a known ceiling. Reversion rules work here and breakout rules will be chopped up until the ceiling gives way.
Limitations
Where this indicator misleads. None of these are fixed by a better parameter.
- Every breakout system built on it suffers a low win rate. Most N-bar highs fail, and the approach only survives because the occasional trend pays for a long series of small losses. That is a psychological problem more than a statistical one.
- The channel is defined by two extreme prints, so a single spike or a bad tick sets the level for the entire lookback and then drops out abruptly, moving the line for no current reason.
- It has no centre of mass and ignores everything that happened between the extremes, so it says nothing about where the market spent its time.
- In range-bound conditions the upper and lower lines become magnets for false breaks, and stop-hunting around obvious N-bar highs is well documented in liquid markets.
Educational reference. This page explains how an indicator is built and how it is commonly read. It is not investment advice, not a recommendation and not a signal service. No indicator is profitable on its own — each is a way of describing a market, and any rule built on one has to be tested with realistic costs before it is traded.