Sidechair

array.some()

Browse the reference

Returns true when at least one item in a bool array is true.

Try it in the editor

The scan ends at the first true item. An empty array is false.

It is the any-of counterpart to array.every(), useful for alerting when at least one of several conditions held.

Syntax

Pine Script
array.some(id: array<bool>) -> series bool
array.some() -> series bool

Arguments

NameTypeDefaultDescription
idarray<bool>requiredThe bool array to test. The call is true when at least one item is true.

Returns

series bool: true when any item is true.

Example

Pine ScriptAny of the last 4 bars gappedOpen in editor
//@version=6
indicator("array.some: recent gap", overlay = true)
var gaps = array.new_bool()
array.push(gaps, math.abs(open - close[1]) > ta.atr(14) * 0.5)
if array.size(gaps) > 4
    array.shift(gaps)
bgcolor(array.some(gaps) ? color.new(color.yellow, 85) : na)

See also

Runs on Sidechair