Max
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
| Name | Type | Default | Description |
|---|---|---|---|
| period | number | 20 | Rolling window size (N-bar high). |
Inputs & Outputs
| Port | Type | Description |
|---|---|---|
| Inputs | ||
| input | number[] | Source numeric array |
| Outputs | ||
| values | number | null | Computed value at each bar; null before the warmup period completes |
| timestamps | number[] | Bar timestamps (UNIX ms), aligned 1-to-1 with values |
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.