Returns the smallest number in an array, or the nth smallest when you pass nth.
array.min(a) is the lowest value, array.min(a, 1) the next lowest, counting nth from 0. Repeated values each take a rank of their own.
Items that are na are ignored. An array without numbers, or an nth beyond the number of values, returns na.
Syntax
array.min(id: array<int/float>, nth: series int) -> series float
array.min(id: array<int>, nth: series int) -> series int
array.min(nth: series int) -> series float
array.min(nth: series int) -> series intArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | array<int/ | required | The numeric array to search. na items are skipped. |
| nth | series int | 0 | Which value to return when the numbers are ranked, starting at 0 for the first. |
Returns
series float or series int: The nth smallest number, or na.
Example
//@version=6
indicator("array.min: lowest two", overlay = true)
var lows = array.new_float()
array.push(lows, low)
if array.size(lows) > 20
array.shift(lows)
plot(array.min(lows), "Lowest", color.red)
plot(array.min(lows, 1), "Next lowest", color.orange)See also
Runs on Sidechair