Max

Windowed · default period 20Statistics

The Max node returns the highest value among all non-null values in the rolling window — equivalent to a rolling highest price or rolling peak. This is the core component of Donchian channel breakout systems, channel upper bands, and any strategy that needs to know the highest point reached over a recent lookback period.

Algorithm

  • output = max(non-null values in window)
  • Returns null if no non-null values exist in window

Parameters

NameTypeDefaultDescription
periodnumber20Rolling window size (N-bar high).

Inputs & Outputs

PortTypeDescription
Inputs
inputnumber[]Source numeric array
Outputs
valuesnumber | nullComputed value at each bar; null before the warmup period completes
timestampsnumber[]Bar timestamps (UNIX ms), aligned 1-to-1 with values
Live mode: In live streaming mode the node updates only the last bar in-place rather than recalculating the full array, keeping CPU usage minimal during real-time data feeds.

Use Cases

Donchian Channel Upper Band

Connect a price high series with period=20 to get the 20-bar high — the Donchian channel upper band. Breakout above triggers a long entry in turtle trading systems.

Trailing Stop Level

Apply Max to closing prices over a short lookback to compute a swing-high trailing stop reference — exit when price falls below this level.

Indicator Peak Detection

Apply Max to an oscillator (RSI, stochastic) to track its recent peak — comparing current value to Max reveals how far the oscillator has pulled back from its high.