Skip to content
Algo Trade Analytics Docs
Pine library page — review pending. This page is preserved for compatibility but is not part of the reviewed search index. Check the official Pine Script v6 reference before relying on its explanation, signature, or example.

matrix - Pine Script Type

Keyword used to explicitly declare the “matrix” type of a variable or a parameter. Matrix objects (or IDs) can be created with the matrix.new function.

  • Matrix objects are always of “series” form.
//@version=6indicator("matrix example")// Create `m1` matrix of `int` type.matrix<int> m1 = matrix.new<int>(2, 3, 0)// `matrix<int>` is unnecessary because the `matrix.new<int>()` function returns an `int` type matrix object.m2 = matrix.new<int>(2, 3, 0)// Display matrix using a label.if barstate.islastconfirmedhistory    label.new(bar_index, high, str.tostring(m2))