Skip to content
Algo Trade Analytics Docs

matrix.columns() - Pine Script Function

The function returns the number of columns in the matrix.

matrix.columns(id) → series int
NameTypeDescription
idany matrix typeA matrix object.

The number of columns in the matrix id.

//@version=6
indicator("`matrix.columns()` Example")// Create a 2x6 matrix with values `0`.var m = matrix.new<int>(2, 6, 0)// Get the quantity of columns in matrix `m`.var x = matrix.columns(m)// Display using a label.
if barstate.islastconfirmedhistory
label.new(bar_index, high, "Columns: " + str.tostring(x) + "\n" + str.tostring(m))