Sidechair

array.range()

Browse the reference

Returns the gap between the largest and the smallest number in an array.

Try it in the editor

It is array.max(a) minus array.min(a), computed in one call. na items are skipped.

A single number gives 0, and an array without numbers gives na.

Syntax

Pine Script
array.range(id: array<int/float>) -> series float
array.range(id: array<int>) -> series int
array.range() -> series float
array.range() -> series int

Arguments

NameTypeDefaultDescription
idarray<int/float> or array<int>requiredThe numeric array to measure. na items are skipped.

Returns

series float or series int: The maximum minus the minimum, or na.

Example

Pine ScriptRange of the last 15 closesOpen in editor
//@version=6
indicator("array.range: close range", overlay = false)
var win = array.new_float()
array.push(win, close)
if array.size(win) > 15
    array.shift(win)
plot(array.range(win), "Range of 15 closes")

See also

Runs on Sidechair