Sidechair

matrix.min()

Browse the reference

Returns the smallest item in a matrix.

Try it in the editor

Every cell is considered, so [[4, -3], [8, 0]] gives -3. A matrix with only na items gives na.

For one row or column, pull it out as an array first and call array.min().

Syntax

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

Arguments

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

Returns

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

Example

Pine ScriptTrough of a gridOpen in editor
//@version=6
indicator("matrix.min: trough", overlay = false)
matrix<float> m = matrix.new<float>(2, 2, 4.0)
matrix.set(m, 0, 1, -2.0)
plot(matrix.min(m), "Smallest")

See also

Runs on Sidechair