Sidechair

array.every()

Browse the reference

Returns true when every item in a bool array is true.

Try it in the editor

The check stops at the first false item. An empty array counts as true, because nothing contradicts the claim.

Collect one condition per bar, per timeframe or per rule in a bool array, then test them all at once.

Syntax

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

Arguments

NameTypeDefaultDescription
idarray<bool>requiredThe bool array to test. The call is true only when every item is true.

Returns

series bool: true when no item is false.

Example

Pine ScriptAll of the last 3 bars closed upOpen in editor
//@version=6
indicator("array.every: three up bars", overlay = true)
var ups = array.new_bool()
array.push(ups, close > open)
if array.size(ups) > 3
    array.shift(ups)
all3 = array.size(ups) == 3 and array.every(ups)
plotshape(all3, "Three up", shape.triangleup, location.belowbar, color.green)

See also

Runs on Sidechair