Calculate the Donchian Channels for a given price series.

Donchian Channels plot the highest high and lowest low over the window periods preceding the current one, with the middle line being the average of the two. They are used to identify breakouts and the overall volatility of the price range.

The formula is as follows:

\[\text{Upper Channel} = \text{Highest High over Window},\;\; \text{ending one period ago}\] \[\text{Lower Channel} = \text{Lowest Low over Window},\;\; \text{ending one period ago}\] \[\text{Middle Channel} = (\text{Upper Channel} + \text{Lower Channel}) / 2\]

The current period is deliberately excluded from the lookback, per Donchian’s original breakout rule and StockCharts’ Price Channels definition - including it would make a channel break impossible by construction.

Also known as: Donchian Channels, price channel breakout.

Donchian Channels in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_donchian_channels as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["HGUSD"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.technicals.get_donchian_channels().xs("HGUSD", level=1, axis="columns").tail(5)

Or, after setting up the Finance Toolkit MCP, ask:

What were the 20-day Donchian Channels of copper from 26 to 31 December 2025?

Which returns:

Date Lower Channel Middle Channel Upper Channel
2025-12-26 5.2425 5.4982 5.754
2025-12-28 5.281 5.5847 5.8885
2025-12-29 5.281 5.6002 5.9195
2025-12-30 5.281 5.6041 5.9272
2025-12-31 5.281 5.6041 5.9272

Parameters

get_donchian_channels accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe time period to consider for historical data. Can be “intraday”, “daily”, “weekly”, “monthly”, “quarterly” or “yearly”. Defaults to “daily”."weekly"
close_columnstrThe column name for closing prices in the historical data. Defaults to “Adj Close”."Close"
windowintNumber of periods for the Donchian Channels. Defaults to 20.55
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).2
growthboolWhether to calculate the growth of the channels. Defaults to False.True
lagint | list[int]The lag to use for the growth calculation. Defaults to 1.4
standardizeboolWhether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.True
Share