How Donchian Channels Are Calculated

Donchian Channels calculation formula inputs limitations.

Direct answer

Donchian Channels are calculated by taking the highest price and the lowest price over a fixed lookback window, then plotting those two rolling extremes as channel boundaries. A common third line is the midpoint, usually the average of the upper and lower boundaries.

A key verification point is that the calculation depends on what “price” means in your dataset (for example, candle highs/lows) and on the exact lookback length (often called the period). If you can reproduce those inputs consistently, you can independently check the indicator values.

Mechanism: definitions and inputs

Core idea

For each point in time (often each candle/bar), Donchian Channels use two rolling functions over the most recent N bars:

  • Upper band = the maximum high over the last N bars.
  • Lower band = the minimum low over the last N bars.

Optionally, many implementations also plot:

  • Mid band = (Upper band + Lower band) / 2.

Inputs you must decide

To calculate Donchian Channels, you need:

  1. A time series of candles or bars (regular intervals) or an equivalent timestamped dataset.
  2. High and low values for each bar. Using highs and lows is the most standard approach; using closes instead would be a different indicator, even if people still loosely call it “Donchian.”
  3. A lookback period N (e.g., 20 bars is common in many contexts, but any integer N can be used).
  4. A rule for alignment: the value at time t is computed from bars within the window ending at t (or sometimes ending at the prior bar, depending on implementation). When verifying, match the implementation’s convention.

Assumptions for a self-check

When you verify the math on your own data, assume:

  • Bars are ordered chronologically.
  • Each bar has a high and a low.
  • The lookback window is exactly the N most recent bars you choose.
  • There is no look-ahead: the upper and lower values at time t must only use information available up to t.

Formula: how the bands are computed

Let:

  • t be the current bar index.
  • N be the lookback period.
  • High[i] be the high of bar i.
  • Low[i] be the low of bar i.

Then the Donchian Channels are typically defined as:

  • Upper(t) = max(High[t−N+1], … , High[t])
  • Lower(t) = min(Low[t−N+1], … , Low[t])
  • Mid(t) = (Upper(t) + Lower(t)) / 2 (optional, but common)

What “rolling” means

“Rolling” means the max and min are recomputed at every new bar:

  • When you advance from t to t+1, the window shifts forward by one bar.
  • The previous farthest bar drops out of the window, and a new bar enters.

This is why the bands can jump: the maximum high or minimum low can change suddenly when an extreme moves into or out of the window.

Evidence or example: compute one step manually

Assume a simplified dataset where the lookback period is N = 3. For a given bar t, suppose the last three bars have:

  • High[t−2] = 1.1000, High[t−1] = 1.1030, High[t] = 1.1010
  • Low[t−2] = 1.0950, Low[t−1] = 1.0960, Low[t] = 1.0970

Then:

  • Upper(t) = max(1.1000, 1.1030, 1.1010) = 1.1030
  • Lower(t) = min(1.0950, 1.0960, 1.0970) = 1.0950
  • Mid(t) = (1.1030 + 1.0950) / 2 = 1.0990

If you repeat this for the next bar t+1, you drop the oldest bar in the window and include the new bar’s high and low. If your numbers differ from an implementation, the difference is usually caused by mismatched inputs (high/low vs close) or mismatched window alignment (including or excluding the current bar).

Limitations and common failure modes

1) Data-definition mismatch

A frequent source of errors is inconsistent definitions across data providers:

  • Some sources may adjust prices (more relevant for long historical series or certain markets).
  • Candle construction depends on the feed, timezone handling, and how the platform aggregates ticks into bars.
  • Missing or illiquid periods can produce atypical high/low values.

Even if the formula is correct, two datasets can yield different channels.

2) “Look-ahead” and alignment confusion

If an implementation uses the window ending at the next bar (intentionally or accidentally), it can be effectively using information not available at time t. When verifying, ensure:

  • The max/min at time t only uses bars up to t.
  • You apply the same indexing convention (ending at t vs ending at t−1).

3) Window-edge behavior

For the earliest bars, you cannot compute the bands until there are at least N bars available. Some platforms output blanks or partial results. This affects early segments and any backtest that starts too close to the beginning.

4) Rolling extremes can be sensitive to spikes

Because the upper band is a rolling maximum and the lower band is a rolling minimum, a single brief spike in high or low can pull a boundary outward for up to N bars. In practice, that means the channel can reflect outliers rather than sustained movement.

5) Relationship to “implications” is not automatic

Even when calculated correctly, the bands are only descriptive functions of past highs and lows. How they are interpreted depends on context and additional rules. The indicator itself does not inherently provide a standalone signal.

Verification and next question

To independently verify Donchian Channels:

  1. Pick a lookback period N.
  2. Use a single consistent price dataset with high and low per bar.
  3. For a few chosen timestamps, compute Upper(t) as the rolling max of highs and Lower(t) as the rolling min of lows.
  4. Confirm whether your midpoint matches (Upper + Lower)/2 if a mid line is included.
  5. Check alignment: verify whether the window includes the current bar.

If you also want to understand when Donchian Channels behave differently from other volatility or range-based tools, a useful next question is how the definition changes across related concepts, especially whether they use highs/lows, closes, or average ranges.

Trading foreign exchange and CFDs involves substantial risk. Information on FoxiForex is educational and is not personal financial advice. Sponsored placements are labelled clearly.