Indicators/probuilder · probacktest · proorder · proscreener

DonchianChannelCenter

DonchianChannelCenter in ProBuilder returns the Donchian Channel middle line, the average of the highest high and lowest low over N bars. Syntax and examples.

Syntax

probuilder
DonchianChannelCenter[period]

Parameters

NameTypeDefaultDescription
periodintegernoneNumber of past bars used to find the highest high and the lowest low. Common values are 20 for daily charts and 55 for longer breakout systems.

Formula

code
DonchianChannelCenter = (Highest[period](high) + Lowest[period](low)) / 2

Equivalently, the average of DonchianChannelUp[period] and DonchianChannelDown[period].

How it works

The Donchian Channel, developed by Richard Donchian, is built from three lines. The upper line is the highest high of the last period bars, the lower line is the lowest low of the same window, and the center line returned by this function is the midpoint of the two.

Unlike a moving average, the center line does not weight every bar. Only the two extreme prices in the window matter, so the line moves in steps: it stays flat while the extremes are unchanged and jumps when a new high or low enters or leaves the lookback window. This step-like behavior makes it a natural equilibrium level for range and trend logic, since price above the center means the market trades closer to its recent highs than its recent lows.

The function reads high and low internally, so it takes no price argument. To build a channel midpoint on a different series, combine Highest and Lowest manually.

Examples

Example 1, Plotting the channel midpoint (Indicator)

probuilder
// Middle line of the 20-bar Donchian Channel
myMiddleLine = DonchianChannelCenter[20]
RETURN myMiddleLine

Draws the midpoint between the 20-bar highest high and lowest low. Plotted on the price chart it tracks the center of the recent trading range.

Example 2, Midline exit for a breakout system (ProOrder)

probuilder
// Enter on a 20-bar breakout, exit when price falls back to the midline
upper  = DonchianChannelUp[20]
center = DonchianChannelCenter[20]

IF NOT LongOnMarket AND close CROSSES OVER upper[1] THEN
  BUY 1 CONTRACT AT MARKET
ENDIF

IF LongOnMarket AND close CROSSES UNDER center THEN
  SELL AT MARKET
ENDIF

A classic Donchian breakout with a midline exit. Using the center line instead of the lower band gives back less open profit in exchange for earlier exits.

Example 3, Screening for price above the channel center (ProScreener)

probuilder
// Distance of the close from the 50-bar channel midpoint, in percent
center = DonchianChannelCenter[50]
dist = (close - center) / center * 100
SCREENER[close > center](dist AS "% above center")

Lists instruments trading above the middle of their 50-bar range and sorts them by how far above the midpoint they sit.

Interpretation

ConditionReading
Close above the center linePrice trades in the upper half of its recent range, a bullish bias.
Close below the center linePrice trades in the lower half of its recent range, a bearish bias.
Center line rising or fallingThe range itself is shifting, new highs or lows are entering the window.

The distance between DonchianChannelUp and DonchianChannelDown measures range width. A narrow channel signals low volatility and compression, a wide channel signals an active market. The center line is often used as a trailing exit level in breakout systems, less aggressive than exiting at the opposite band.

Common errors and gotchas

  • Passing a price argument. DonchianChannelCenter[20](close) is not the documented form. The function takes only the bracketed period and works on the instrument's highs and lows directly.
  • Confusing it with a moving average. The center line depends only on the two extremes of the window, so it stays flat for long stretches and jumps discretely. Crossover logic tuned for smooth averages behaves differently on this line.
  • Lookahead at the current bar. On the live bar the channel includes the bar's forming high and low. For breakout comparisons, reference the previous bar's value, for example DonchianChannelUp[20][1], to avoid a level that moves with the tick.
  • Period of 1. DonchianChannelCenter[1] returns the current bar's median price, which is rarely intended. Very short periods reduce the channel to bar-level noise.