Donchian Channels

The highest high and lowest low of recent candles, as a channel.

Donchian channels over period candles that end from candles back: upper = highest high, lower = lowest low, middle = (upper + lower) ÷ 2. from = 1 (default) uses the previous candles only, the current candle is EXCLUDED (so close > upper is a breakout); from = 0 includes the current candle. Ready at period + from candles.

Settings

SettingDefaultRangeWhat it does
period201 to 1000Candles in the window.
from10 to 1000Candles back where the window ends (1 = current excluded).

What it gives

OutputWhat it is
Upper channelHighest high of the window.
Lower channelLowest low of the window.
Middle line(upper + lower) ÷ 2.

What it reads

It reads the whole candle (open, high, low, close and volume).

Warm-up

With its default settings, Donchian Channels needs 21 closed candles before its first value. A backtest loads them before its start date, so the first trade can already use it.

Test it

Copy this sentence into the Algonney chat to backtest it:

Backtest a strategy on BTC that uses Donchian Channels with its default settings