Donchian Channel
systemic:core-dcIndicatorsInputs
| Name | Type | Description |
|---|---|---|
| Window | Whole number | The number of bars used to calculate the channel bands. |
| Offset | Whole number | The number of bars by which the output bands are shifted in time. |
| Price High | Number series | The highest price of each bar (e.g., the daily high). |
| Price Low | Number series | The lowest price of each bar (e.g., the daily low). |
| Price Close | Number series | The closing price of each bar (e.g., the daily close). |
Outputs
| Name | Type | Description |
|---|---|---|
| Upper Band | Number series | The highest high over the window. |
| Lower Band | Number series | The lowest low over the window. |
| Middle Band | Number series | The midpoint between the upper and lower bands. |
| Percentage Band | Number series | The position of the closing price within the channel, from 0 (lower band) to 1 (upper band). |
| Width Band | Number series | The channel width as a percentage of the average closing price over the window. |
Cost
0.213 + 0.0284·n credits for n bars, rounded up. The marks are each plan's limit of bars.
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 the window.
- Lower Band: The lowest low over the window.
- Middle Band: The average of the Upper and Lower Bands.
Why Donchian Channel matters:
- Breakout detection: Highlights new highs/lows, which can mark entry/exit points.
- Trend following: Helps traders stay with a trend until a reversal signal appears.
- Volatility insight: Channel width reflects market volatility.
- Cross-asset utility: Used in stocks, futures, forex, and crypto.
Quick links:
How It Works
The Upper and Lower Bands use only price highs and lows over a window that you set (commonly 20 bars).
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. With Offset 0 the bands include the current bar, so the close cannot leave the channel. Set Offset to 1 to compare the close with the channel of the previous bars.
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 windows = 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
- Period: DC works on any period (daily, hourly, etc.), but signals are more reliable on longer periods.
- Window 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 window
- Lower Band: Lowest low over the window
- 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 (comparable across assets) |
Percentage Band (pband)
The percentage band shows where the close sits 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)
It stays between 0 and 1 when Close lies between Low and High of the same bar.
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:
- A bar is missing if High, Low, or Close is empty there. All five outputs are empty on that bar.
- Gaps are never filled with 0, with the previous value, or with a value from a later bar.
- "N-bar window" means N bars with data: a weekend or holiday gap is skipped (Friday's 20-bar window continues into Monday). It is not counted as a zero-change bar.
- Warm-up: the first
window-1 bars with data (plusoffsetmore ifoffset> 0) are empty. With a negativeoffset, the last bars are empty instead. - pband is empty when the channel width is exactly 0 (hband equals lband).
Data Alignment in Systemic
The Donchian Channel needs three aligned price inputs (High, Low, Close) plus two constants (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 | Number of bars in the window (no alignment needed) |
| Offset | Constant | Shift output by N bars |
Automatic Alignment
If your price inputs have different periods:
- All inputs are placed on the bars of the fastest series
- A slower series repeats its last value until its next one
Critical: All three price series should come from the same asset and period. Mixing price data from different sources gives channels with no meaning.
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. |
| Versatility | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | Works across all periods 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 and sound risk management, and always test your strategy on historical data first.