Sidechair

matrix.is_zero()

Browse the reference

Returns true when every item in a matrix is 0.

Try it in the editor

Every item must be 0: [[0, 0], [0, 0]] passes and [[0, 0], [0, 0.001]] fails.

Subtracting a matrix from itself leaves zeros, so matrix.is_zero(matrix.diff(a, b)) tests whether a and b hold the same items.

Syntax

Pine Script
matrix.is_zero(id: matrix<int/float>) -> series bool
matrix.is_zero() -> series bool

Arguments

NameTypeDefaultDescription
idmatrix<int/float>requiredThe matrix checked for items that are all 0; a single non-zero item makes the result false.

Returns

  • series bool: true when every item is 0, otherwise false.
  • series bool: true when the receiving matrix holds only zeros, otherwise false.

Example

Pine ScriptCompare two matricesOpen in editor
//@version=6
indicator("matrix.is_zero: equal?", overlay = false)
matrix<float> a = matrix.new<float>(2, 2, 3.0)
b = matrix.copy(a)
plot(matrix.is_zero(matrix.diff(a, b)) ? 1 : 0, "Equal")

See also

Runs on Sidechair