Donchian Channel
systemic:core-dcIndicatorsfunction1 crInputs
| Name | Type | Description |
|---|---|---|
| Window | integer | The lookback period for calculating the channel bands. |
| Offset | integer | Shifts the output bands forward or backward in time. |
| Price High | floatarray | The highest price recorded within each period (e.g., the daily high). |
| Price Low | floatarray | The lowest price recorded within each period (e.g., the daily low). |
| Price Close | floatarray | The closing price at the end of each period (e.g., the daily close). |
Outputs
| Name | Type | Description |
|---|---|---|
| Upper Band | floatarray | The highest high over the specified lookback window. |
| Lower Band | floatarray | The lowest low over the specified lookback window. |
| Middle Band | floatarray | The midpoint between the upper and lower bands. |
| Percentage Band | floatarray | The normalized position of the closing price within the channel. |
| Width Band | floatarray | The channel width, relative to the average closing price over the window — a percentage, not |
A practical guide to using the Donchian Channel (DC) for identifying breakouts, following trends, and measuring volatility in both traditional and crypto markets.
Overview
The Donchian Channel is a classic trend-following indicator developed by Richard Donchian. It consists of three lines:
- Upper Band: The highest high over a specified period.
- Lower Band: The lowest low over a specified period.
- Middle Band: The average of the Upper and Lower Bands.
Why Donchian Channel matters:
- Breakout detection: Highlights new highs/lows, signaling potential entry/exit points.
- Trend following: Helps traders ride trends by staying in positions until a reversal is signaled.
- Volatility insight: Channel width reflects market volatility.
- Cross-asset utility: Used in stocks, futures, forex, and crypto.
Quick links:
How It Works
The Donchian Channel is calculated using only price highs and lows over a user-defined window (commonly 20 periods).
Formulas
Upper Band:
Lower Band:
Middle Band:
Calculation Flow
flowchart TD
Price[High, Low Series] --> Upper[Find Highest High]
Price --> Lower[Find Lowest Low]
Upper --> Middle[Average with Lower Band]
Lower --> Middle
Upper[Upper Band]
Lower[Lower Band]
Middle[Middle Band]
Interpretation and Use Cases
Typical Ranges
- Bands: Dynamic, based on recent highs/lows. Wider = more volatile, narrower = less volatile.
- Price vs Bands: Price above Upper Band = breakout; below Lower Band = breakdown.
Signal Logic
- Breakout Buy: Price closes above Upper Band → potential long entry.
- Breakout Sell: Price closes below Lower Band → potential short entry.
- Trend following: Stay long while price above Middle Band, short while below.
- Volatility regime: Channel width expands in high volatility, contracts in low volatility.
Practical Use Cases
- Classic trend following: Enter long on breakout above Upper Band, exit on breakdown below Lower Band (or vice versa for shorts). Used in Turtle Trading and systematic CTA strategies.
- Crypto volatility filter: In crypto, use channel width to filter out trades during low-volatility periods and focus on breakouts.
- Range trading: In sideways markets, fade moves near the bands, betting on mean reversion.
- Trailing stop: Use the Lower Band as a trailing stop for long positions, Upper Band for shorts.
- Multi-indicator systems: Combine DC with momentum (e.g., RSI) or volume (e.g., OBV) for higher conviction signals.
Edge Cases and Pitfalls
- False breakouts: In choppy/range-bound markets, DC can generate whipsaws.
- Lagging effect: As a trend-following indicator, DC may signal late entries/exits after a move has started.
- Overfitting: Shorter periods = more signals/noise; longer = smoother but slower.
- Crypto gaps: 24/7 trading in crypto can lead to more frequent band touches than in traditional markets.
Example: Breakout Signal
- Price closes above the 20-day Upper Band → enter long.
- Price closes below the 20-day Lower Band → enter short or exit long.
Decision Flow Example
flowchart TD
S[New Price Close] --> A{Above Upper Band?}
A -->|Yes| B[Breakout Buy Signal]
A -->|No| C{Below Lower Band?}
C -->|Yes| D[Breakout Sell Signal]
C -->|No| E[No Breakout]
Data Notes & Practical Usage
- Frequency: DC works on any timeframe (daily, hourly, etc.), but signals are more reliable on higher timeframes.
- Period selection: 20 is standard, but shorter = more signals/noise; longer = smoother, slower signals.
- Asset class: Crypto and commodities often show more frequent breakouts due to higher volatility.
- Pitfalls: Avoid overfitting; test on out-of-sample data.
Implementation & Backtesting Notes
- Data hygiene: Use consistent, high-quality price data; avoid look-ahead bias.
- Risk management: Use DC with stop-losses and position sizing; avoid trading every signal in choppy markets.
- Combine with other indicators: DC is best as part of a system, not standalone.
- Backtesting: Validate signals across different market regimes and liquidity conditions.
Comparison: Donchian Channel vs. Other Channel/Breakout Indicators
| Indicator | Measures | Output | Best For |
|---|---|---|---|
| Donchian Channel | Price highs/lows | Bands | Breakouts, trend following |
| Bollinger Bands | SMA & Std. Dev. | Bands | Volatility, mean reversion |
| Keltner Channel | EMA & ATR | Bands | Trend, volatility, breakouts |
| ATR Bands | ATR around price | Bands | Volatility regime, stops |
- Donchian Channel is pure price-based, best for breakout and trend systems.
- Bollinger Bands adapt to volatility, better for mean reversion and volatility breakouts.
- Keltner Channel uses ATR, smoother and less sensitive to price spikes.
- ATR Bands are best for volatility targeting and dynamic stops.
Glossary
- Upper Band: Highest high over the lookback period
- Lower Band: Lowest low over the lookback period
- Middle Band: Average of Upper and Lower Bands
- Breakout: Price moves above/below recent extremes
- Whipsaw: False breakout or reversal, often in choppy markets
- Backtesting: Simulating a strategy on historical data
All Outputs Explained
The Donchian Channel module provides five outputs, each serving a distinct purpose:
| Output | Name | Formula | Purpose |
|---|---|---|---|
| hband | Upper Band | Breakout detection, resistance | |
| lband | Lower Band | Breakdown detection, support | |
| mband | Middle Band | Trend center, equilibrium price | |
| pband | Percentage Band | Position within channel (0-1) | |
| wband | Width Band | Volatility measure, as a percent of average close (scale-invariant across assets) |
Percentage Band (pband)
The percentage band normalizes price position within the channel:
- 0.0: Price at the lower band (breakdown zone)
- 0.5: Price at the middle band (equilibrium)
- 1.0: Price at the upper band (breakout zone)
- >1.0: Price above the channel (strong breakout)
- <0.0: Price below the channel (strong breakdown)
Width Band (wband)
Channel width, expressed as a percent of the average closing price over the window (not a raw price spread) — this makes wband comparable across assets and price scales:
- Expanding width: Increasing volatility (trend in progress)
- Contracting width: Decreasing volatility (consolidation)
- Breakout with expanding width: Healthy trend confirmation
Missing Data
Donchian Channel treats a gap (closed market, unavailable bar) as a missing bar, never a fabricated one:
- A bar is missing if High, Low, or Close is unavailable there — all five outputs are
Noneat that position. - No sentinel fills: gaps never become 0, a carried-forward stale value, or a look-ahead value borrowed from a later bar.
- "N-bar window" means N observed bars: a weekend or holiday gap is bridged (Friday's 20-bar window continues into Monday), never counted as a zero-change bar and never left to starve the window forever.
- Warm-up: the first
window-1 observed bars (plusoffsetmore ifoffset> 0) are honestlyNone— never a fabricated partial-window value. - pband's
0/0case (channel width is exactly 0 — hband equals lband) isNone, not a fabricated 0.0 or 50.0.
Data Alignment in Systemic
The Donchian Channel requires three aligned price inputs (High, Low, Close) plus two constant parameters (Window, Offset).
Input Requirements
| Input | Type | Alignment Behavior |
|---|---|---|
| Price High | Series | Must match length of Low and Close |
| Price Low | Series | Must match length of High and Close |
| Price Close | Series | Must match length of High and Low |
| Window | Constant | Lookback period (no alignment needed) |
| Offset | Constant | Shift output by N periods |
Automatic Alignment
If your price inputs have different frequencies:
- All inputs are upsampled to the finest resolution
- Forward-fill is applied to maintain the last known value
Critical: All three price series should come from the same asset and timeframe. Mixing price data from different sources produces invalid Donchian Channels.
Indicator Assessment
%%{init: {"themeVariables": {"cScale0": "#4F46E5", "cScale1": "#059669"}}}%%
quadrantChart
title Donchian Channel Assessment
x-axis Low --> High
y-axis Low --> High
quadrant-1 High Popularity & Reliability
quadrant-2 High Reliability & Low Popularity
quadrant-3 Low Reliability & Popularity
quadrant-4 High Popularity & Low Reliability
"Traditional Markets": [0.80, 0.85]
"Cryptocurrency": [0.65, 0.70]
| Dimension | Stocks/Macro | Crypto | Explanation |
|---|---|---|---|
| Popularity | ⭐⭐⭐⭐ | ⭐⭐⭐ | A classic indicator made famous by the Turtle Trading system. Well-known in commodities and futures. Less common in crypto, where Bollinger Bands are often preferred. |
| Reliability | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | Excellent for trend-following in trending markets. Crypto's higher volatility produces more frequent but sometimes false breakout signals. |
| Complexity | ⭐ | ⭐ | One of the simplest channel indicators—just the highest high and lowest low. No complex calculations required. |
| Versatility | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | Works across all timeframes and asset classes. Best suited for trend-following strategies; less effective in range-bound markets. |
| Recent Interest | ⭐⭐⭐ | ⭐⭐⭐ | Steady interest as a classic indicator. Periodically resurfaces when systematic trend-following strategies gain attention. |
References and Further Reading
- Investopedia: Donchian Channel
- Binance Academy: Donchian Channel
- StockCharts: Donchian Channel
- TradingView: Donchian Channel
For best results, use Donchian Channel with other indicators, robust risk management, and always backtest your strategy before live trading.