Skip to content
Algo Trade Analytics Docs

matrix.pow() - Pine Script Function

The function calculates the product of the matrix by itself power times.

matrix.pow(id, power) → matrix<float>
NameTypeDescription
idmatrix<int/float>A matrix object.

The product of the id matrix by itself power times.

//@version=6
indicator("`matrix.pow()` Example")// Display using a table.
if barstate.islastconfirmedhistory // Create a 2x2 matrix.
var m1 = matrix.new<int>(2, 2, 2) // Calculate the power of three of the matrix.
var m2 = matrix.pow(m1, 3) // Display matrix elements.
var t = table.new(position.top_right, 2, 2, color.green)
table.cell(t, 0, 0, "Original Matrix:")
table.cell(t, 0, 1, str.tostring(m1))
table.cell(t, 1, 0, "Matrix³:")
table.cell(t, 1, 1, str.tostring(m2))