Sidechair

matrix.max()

Browse the reference

Returns the largest item in a matrix.

Try it in the editor

The whole grid is searched, not one row or column: [[1, 9], [4, 2]] gives 9. An all-na matrix gives na.

Use matrix.row() or matrix.col() with array.max() to find the largest item in a single line.

Syntax

Pine Script
matrix.max(id: matrix<int/float>) -> series float
matrix.max(id: matrix<int>) -> series int
matrix.max() -> series float
matrix.max() -> series int

Arguments

NameTypeDefaultDescription
idmatrix<int/float> or matrix<int>requiredThe matrix searched in full for its largest item, across every row and column.

Returns

  • series float: The largest item as a float.
  • series int: The largest item as a whole number, to match an integer matrix.
  • series float: The largest item of the receiving matrix as a float.
  • series int: The largest item of the receiving matrix as a whole number.

Example

Pine ScriptPeak of a gridOpen in editor
//@version=6
indicator("matrix.max: peak", overlay = false)
matrix<float> m = matrix.new<float>(2, 2, 1.0)
matrix.set(m, 1, 0, 8.0)
plot(matrix.max(m), "Largest")

See also

Runs on Sidechair