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
DonchianChannelCenter[period]Parameters
| Name | Type | Default | Description |
|---|---|---|---|
period | integer | none | Number 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
DonchianChannelCenter = (Highest[period](high) + Lowest[period](low)) / 2Equivalently, 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)
// Middle line of the 20-bar Donchian Channel
myMiddleLine = DonchianChannelCenter[20]
RETURN myMiddleLineDraws 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)
// 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
ENDIFA 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)
// 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
| Condition | Reading |
|---|---|
| Close above the center line | Price trades in the upper half of its recent range, a bullish bias. |
| Close below the center line | Price trades in the lower half of its recent range, a bearish bias. |
| Center line rising or falling | The 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.
Related instructions
DonchianChannelUp, upper channel line, the highest high of the window.DonchianChannelDown, lower channel line, the lowest low of the window.Highest, highest value of any series over N bars.Lowest, lowest value of any series over N bars.KeltnerBandCenter, midline of the Keltner channel, an ATR-based alternative.BollingerUp, upper Bollinger band, a standard-deviation channel.BollingerDown, lower Bollinger band.Average, simple moving average, a smoother central reference.
