Donchian Channels
All indicators

LibraryVolatility

Indicator

Donchian Channels

The highest high and the lowest low of the last bars, with their midpoint. The channel shows the range the market has traded in over the length.

VolatilityOn the price1 inputDC

How it is calculated

The upper line is the highest high and the lower line the lowest low of the last length bars, the current bar included. The middle line is their average. There is no smoothing; the first value comes once the length is filled. After Richard Donchian, with TA-Lib MAX and MIN.

Reference: Donchian channels (TA-Lib MAX and MIN)

How to read it

A rising upper line means price made a new high for the period, the classic breakout. The lines stay flat while nothing new happens and jump when an old extreme leaves the window. Since the current bar is in the window, its high can never lie above its own upper line.

In a strategy

A breakout system in the style of the Turtles: buy when the high exceeds the upper line of the bar before, ctx.ind("dc", length=20).upper read one bar earlier, and exit on the lower line of a shorter channel.

Inputs

InputTypeDefaultRange or choices
LengthlengthWhole number20min 1, max 5000

What it draws

LineDrawn as
UpperLine
MiddleLine
LowerLine

Used in

No strategy template reads it yet.

OrionQuant