Sidechair

matrix.elements_count()

Browse the reference

Returns how many items a matrix holds in total: rows times columns.

Try it in the editor

A 3 by 4 matrix has 12 elements. Use it to check a matrix against the 100,000 element limit or before a reshape, which needs the same count.

An empty matrix has 0.

Syntax

Pine Script
matrix.elements_count(id: any matrix type) -> series int
matrix.elements_count() -> series int

Arguments

NameTypeDefaultDescription
idany matrix typerequiredThe matrix to count items in.

Returns

series int: The number of elements.

Example

Pine ScriptSize of a gridOpen in editor
//@version=6
indicator("matrix.elements_count: size", overlay = false)
matrix<int> m = matrix.new<int>(3, 4, 0)
plot(matrix.elements_count(m), "Elements")

See also

Runs on Sidechair