Skip to content
Algo Trade Analytics Docs

matrix.det() - Pine Script Function

The function returns the determinant of a square matrix.

matrix.det(id) → series float
NameTypeDescription
idmatrix<int/float>A matrix object.

The determinant value of the id matrix.

  • Function calculation based on the LU decomposition algorithm.
//@version=6
indicator("`matrix.det` Example")// Create a 2x2 matrix.var m = matrix.new<float>(2, 2, na)// Fill the matrix with values.matrix.set(m, 0, 0, 3)
matrix.set(m, 0, 1, 7)
matrix.set(m, 1, 0, 1)
matrix.set(m, 1, 1, -4)// Get the determinant of the matrix.var x = matrix.det(m)
plot(x, 'Matrix determinant')