Indicators/probuilder · probacktest · proorder · proscreener

DonchianChannelUp

DonchianChannelUp in ProBuilder returns the upper Donchian Channel line, the highest high over the last N bars. Syntax, formula, examples, and gotchas.

Syntax

probuilder
DonchianChannelUp[period]

Parameters

NameTypeDefaultDescription
periodintegernoneNumber of past bars used to find the highest high. 20 is the classic value, 55 is common for slower breakout systems.

Formula

code
DonchianChannelUp = Highest[period](high)

The upper line of the Donchian Channel, equivalent to calling Highest on the high series.

How it works

The Donchian Channel is made of three lines: the highest high of the last period bars (this function), the lowest low of the same window (DonchianChannelDown), and their average (DonchianChannelCenter). DonchianChannelUp scans the lookback window on each bar and returns the largest high found.

The line moves in discrete steps. A new bar that prints a higher high pushes the line up immediately. When the old highest high leaves the window without being exceeded, the line steps down to the next-highest value. In between, the line is flat, forming the staircase profile characteristic of Donchian lines.

The upper line reads as objective resistance: it is the exact price the market has failed to exceed during the window. A close or trade above it means a fresh period-bar high, the event that trend-following breakout systems use for long entries and short exits. The channel's width, the distance down to DonchianChannelDown, doubles as a simple volatility gauge.

Examples

Example 1, Plotting the upper channel line (Indicator)

probuilder
// Highest high of the last 20 bars
myUpperLine = DonchianChannelUp[20]
RETURN myUpperLine

Draws the 20-bar highest high on the price chart. Price touching the line means the market is printing new 20-bar highs.

Example 2, Donchian breakout entry (ProOrder)

probuilder
// Buy a break of the prior 20-bar high, trail out at the 10-bar low
entryline = DonchianChannelUp[20]
exitline  = DonchianChannelDown[10]

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

IF LongOnMarket AND close CROSSES UNDER exitline[1] THEN
  SELL AT MARKET
ENDIF

The 20/10 Donchian breakout pattern. Both channel values reference the previous bar so the levels stay fixed while the current bar forms.

Example 3, Screening for new 50-bar highs (ProScreener)

probuilder
// Instruments closing above their previous 50-bar high
upper = DonchianChannelUp[50]
brk = close - upper[1]
SCREENER[close > upper[1]](brk AS "Breakout distance")

Lists instruments that closed above their previous 50-bar highest high and ranks them by how far the close cleared the level.

Interpretation

ConditionReading
Price breaks above the lineNew period-bar high, upside breakout.
Price rejected at the lineThe window's high held, short-term resistance confirmed.
Line flat for many barsNo new highs, the market is consolidating or declining.
Line stepping up repeatedlyPersistent buying, an established uptrend.

A narrow channel, upper line close to DonchianChannelDown, signals compression that often precedes directional moves. A wide channel signals high volatility. Trend followers typically buy strength at the upper line rather than fading it.

Common errors and gotchas

  • Self-referencing breakout test. The current bar's high is part of the window, so high > DonchianChannelUp[20] is never true. Compare against the previous bar's value, DonchianChannelUp[20][1], when testing for a breakout.
  • Passing a price argument. The function accepts only the bracketed period and always works on the instrument's highs. For the highest value of another series, use Highest[period](series).
  • Whipsaw in ranging markets. Breakouts of the upper line fail frequently in sideways conditions. Most Donchian systems add a trend or volatility filter rather than trading every new high.
  • Assuming smooth crossovers. The line jumps in steps rather than gliding. CROSSES OVER logic can trigger on a level jump rather than a price move, so verify signals against the price series itself.