Skip to content
Algo Trade Analytics Docs

matrix.max() - Pine Script Function

The function returns the largest value from the matrix elements.

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

The maximum value from the id matrix.

//@version=6
indicator("`matrix.max()` Example")// Create a 2x2 matrix.var m = matrix.new<int>(2, 2, na)// Fill the matrix with values.matrix.set(m, 0, 0, 1)
matrix.set(m, 0, 1, 2)
matrix.set(m, 1, 0, 3)
matrix.set(m, 1, 1, 4)// Get the maximum value in the matrix.var x = matrix.max(m)
plot(x, 'Matrix maximum value')