array.max() - Pine Script Function
array.max()
Section titled “array.max()”Overview
Section titled “Overview”The function returns the greatest value, or the nth greatest value in a given array.
Syntax
Section titled “Syntax”array.max(id, nth) → series floatParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| id | array<int/float> | An array object. |
Returns
Section titled “Returns”The greatest or the nth greatest value in the array.
Remarks
Section titled “Remarks”- Returns na if the id array is empty.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("array.max")a = array.from(5, -2, 0, 9, 1)thirdHighest = array.max(a, 2) // 1plot(thirdHighest)