Indicators/probuilder · probacktest · proorder · proscreener

Highest

Highest[N](price) in ProBuilder returns the maximum value of a price series over the last N bars, used for breakout levels, resistance and channel bands.

Syntax

probuilder
Highest[N](price)

Parameters

NameTypeDefaultDescription
NintegernoneNumber of bars in the lookback window, counted from the current bar backwards.
priceprice sourcenoneSeries to scan, for example close, high, low, volume, or any custom variable or indicator output.

Formula

code
Highest[N](price) = max(price, price[1], ..., price[N-1])

The window covers the current bar and the N - 1 bars before it.

How it works

On every bar, ProBuilder scans the last N values of the given series and returns the largest one. The argument is not limited to raw prices: any expression that produces a series can be scanned, so the maximum of an RSI, a volume stream, or a custom calculation works the same way.

The function underpins many classic constructions. Highest[N](high) is the upper Donchian channel line and the standard breakout reference. Comparing the current bar against Highest[N](close) detects new N-bar closing highs. The companion function Lowest provides the mirror value, and HighestBars reports how many bars ago the maximum occurred rather than its value.

When the level should represent past bars only, excluding the current one, shift the whole expression by one bar with Highest[N](high)[1]. This distinction matters for breakout logic, because on the breakout bar itself the unshifted version already includes the new high, so high > Highest[N](high) can never be true.

Examples

Example 1, Upper band from recent extremes (Indicator)

probuilder
// Track the greater of the current high and the highest close of the last 10 bars
IF (High > Highest[10](close)) THEN
  bandH = High
ELSE
  bandH = Highest[10](close)
ENDIF
RETURN bandH

Compares the current bar's high with the highest close of the last 10 bars and plots whichever is greater, a simple adaptive upper band.

Example 2, Donchian breakout entry (ProOrder)

probuilder
// Buy a stop breakout of the 20-bar high, exit under the 10-bar low
entryLevel = Highest[20](high)[1]
exitLevel  = Lowest[10](low)[1]

IF NOT LongOnMarket THEN
  BUY 1 CONTRACT AT entryLevel STOP
ELSE
  SELL AT exitLevel STOP
ENDIF

Places a pending stop order at the previous 20-bar high. The [1] shift excludes the current bar so the level is fixed while the bar forms.

Example 3, New 52-week high screener (ProScreener)

probuilder
// Daily-bar screener: close within 1 percent of the 252-bar high
hi52 = Highest[252](high)
SCREENER[close >= hi52 * 0.99](close AS "Close")

Returns instruments closing within 1 percent of their highest high of the last 252 daily bars, an approximation of the 52-week-high list.

Interpretation

Highest is a utility rather than a signal generator, but the levels it produces carry standard readings. Price pressing against its N-bar high signals strength; a close beyond it is a breakout, the basis of Donchian and turtle-style systems. The distance between Highest[N](high) and Lowest[N](low) measures the range's width, and a narrowing distance flags contraction that often precedes expansion. Larger N values produce levels that are touched less often and are treated as more significant.

Common errors and gotchas

  • Breakout test that can never trigger. high > Highest[20](high) is always false because the window includes the current bar. Use the shifted form, high > Highest[20](high)[1], to compare against prior bars only.
  • Wrong bracket type. The period goes in square brackets and the series in parentheses: Highest[10](close). Highest(10, close) raises a syntax error.
  • Window exceeding loaded history. If N is larger than the number of bars available on the chart or preloaded in a strategy, early values are computed on incomplete data. Increase the loaded history or guard with BarIndex.
  • Confusing value with position. Highest returns the extreme value itself. To know how many bars ago it occurred, use HighestBars, mixing the two is a frequent logic bug.
  • Lowest, minimum value over the last N bars.
  • HighestBars, number of bars since the highest value occurred.
  • LowestBars, number of bars since the lowest value occurred.
  • DonchianChannelUp, prebuilt upper Donchian channel line.
  • DonchianChannelDown, prebuilt lower Donchian channel line.
  • High, the per-bar high price constant.
  • MAX, maximum of two expressions on the same bar.
  • Supertrend, alternative trend-following level.