ArgMax
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
| Name | Type | Default | Description |
|---|---|---|---|
| period | number | 20 | Rolling window size. |
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
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.