Donchian Channels
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.
No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Donchian Channels for you. Just ask in plain English.
Calculate the Donchian Channels in Python
The Donchian Channels is available in the Technicals module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_donchian_channels as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(tickers=["AAPL", "MSFT"])
toolkit.technicals.get_donchian_channels().xs("AAPL", level=1, axis="columns")
Which returns:
| Date | Lower Channel | Middle Channel | Upper Channel |
|---|---|---|---|
| 2026-06-18 | 279.4 | 300.13 | 320.86 |
| 2026-06-22 | 279.4 | 299.4 | 319.4 |
| 2026-06-23 | 279.4 | 298.7 | 318 |
| 2026-06-24 | 275.15 | 296.87 | 318.6 |
| 2026-06-25 | 275.15 | 296.87 | 318.6 |
| 2026-06-26 | 275.15 | 296.87 | 318.6 |
| 2026-06-29 | 275.15 | 296.87 | 318.6 |
| 2026-06-30 | 275.15 | 296.87 | 318.6 |
| 2026-07-01 | 275.15 | 296.87 | 318.6 |
| 2026-07-02 | 275.15 | 296.87 | 318.6 |
Parameters
get_donchian_channels accepts the following parameters:
- period (str, optional): The time period to consider for historical data. Can be “daily”, “weekly”, “quarterly”, or “yearly”. Defaults to “daily”.
- close_column (str, optional): The column name for closing prices in the historical data. Defaults to “Adj Close”.
- window (int, optional): Number of periods for the Donchian Channels. Defaults to 20.
- rounding (int | None, optional): The number of decimals to round the results to. Defaults to 4.
- growth (bool, optional): Whether to calculate the growth of the channels. Defaults to False.
- lag (int | list[int], optional): The lag to use for the growth calculation.
- standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. Defaults to 1.
Related Volatility Indicators
The Technicals module page introduces the module, and the sidebar lists all of its functions.