ArgMax

Windowed · default period 20Statistics

The ArgMax node returns the 0-based index (position within the window) of the highest value in the lookback period. Index period−1 means the peak is at the most recent bar; index 0 means the peak was period bars ago. Useful for detecting swing highs, measuring peak age, and comparing peak positions across indicators for divergence analysis.

Algorithm

  • Iterate through the window and track the index of the maximum non-null value
  • output = 0-based index of the maximum value within the window
  • Returns null if window has no non-null values

Parameters

NameTypeDefaultDescription
periodnumber20Rolling window size.

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

Swing High Detection

If ArgMax returns period−1, the current bar is the highest bar in the window — a classic pivot high detection mechanism.

Peak Age

Subtract ArgMax from period−1 to get the "age" of the peak in bars. A large age with flat subsequent movement suggests distribution near resistance.

Divergence Between Price and Indicator

If ArgMax(price high) returns a lower index than ArgMax(RSI), price made a new high more recently than RSI did — a classic bearish divergence signal.