Systemicbeta

Donchian Channel

systemic:core-dcIndicators

Inputs

NameTypeDescription
WindowWhole numberThe number of bars used to calculate the channel bands.
OffsetWhole numberThe number of bars by which the output bands are shifted in time.
Price HighNumber seriesThe highest price of each bar (e.g., the daily high).
Price LowNumber seriesThe lowest price of each bar (e.g., the daily low).
Price CloseNumber seriesThe closing price of each bar (e.g., the daily close).

Outputs

NameTypeDescription
Upper BandNumber seriesThe highest high over the window.
Lower BandNumber seriesThe lowest low over the window.
Middle BandNumber seriesThe midpoint between the upper and lower bands.
Percentage BandNumber seriesThe position of the closing price within the channel, from 0 (lower band) to 1 (upper band).
Width BandNumber seriesThe channel width as a percentage of the average closing price over the window.

Cost

29
credits per run
1,000
bars

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:

Upper Band=max⁡(High over window)\text{Upper Band} = \max(\text{High over window})

Lower Band:

Lower Band=min⁡(Low over window)\text{Lower Band} = \min(\text{Low over window})

Middle Band:

Middle Band=Upper Band+Lower Band2\text{Middle Band} = \frac{\text{Upper Band} + \text{Lower Band}}{2}

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

IndicatorMeasuresOutputBest For
Donchian ChannelPrice highs/lowsBandsBreakouts, trend following
Bollinger BandsSMA & Std. Dev.BandsVolatility, mean reversion
Keltner ChannelEMA & ATRBandsTrend, volatility, breakouts
ATR BandsATR around priceBandsVolatility 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:

OutputNameFormulaPurpose
hbandUpper Bandmax⁡(Hight−n:t)\max(\text{High}_{t-n:t})Breakout detection, resistance
lbandLower Bandmin⁡(Lowt−n:t)\min(\text{Low}_{t-n:t})Breakdown detection, support
mbandMiddle Bandhband+lband2\frac{\text{hband} + \text{lband}}{2}Trend center, equilibrium price
pbandPercentage BandClose−lbandhband−lband\frac{\text{Close} - \text{lband}}{\text{hband} - \text{lband}}Position within channel (0-1)
wbandWidth Bandhband−lbandmean(Close)×100\frac{\text{hband} - \text{lband}}{\text{mean}(\text{Close})} \times 100Volatility 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 (plus offset more if offset > 0) are empty. With a negative offset, 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

InputTypeAlignment Behavior
Price HighSeriesMust match length of Low and Close
Price LowSeriesMust match length of High and Close
Price CloseSeriesMust match length of High and Low
WindowConstantNumber of bars in the window (no alignment needed)
OffsetConstantShift 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]
DimensionStocks/MacroCryptoExplanation
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


For best results, use Donchian Channel with other indicators and sound risk management, and always test your strategy on historical data first.

Rendering diagrams...
© 2026 WanoLabs. All rights reservedBeta v0.1.5