Sidechair

math.min()

Browse the reference

Returns the smallest of the numbers you pass; na if any of them is na.

Try it in the editor

math.min compares two or more numbers on the current bar and returns the smallest. Any count of arguments is allowed, and mixed ints and floats give a float.

It works across arguments on one bar, not across bars. For a rolling minimum use ta.lowest, and for the smallest value on record use ta.min.

Syntax

Pine Script
math.min(number0, number1, ...: const int) -> const int
math.min(number0, number1, ...: const int/float) -> const float
math.min(number0, number1, ...: simple int) -> simple int
math.min(number0, number1, ...: simple int/float) -> simple float
math.min(number0, number1, ...: input int) -> input int
math.min(number0, number1, ...: input int/float) -> input float
math.min(number0, number1, ...: series int) -> series int
math.min(number0, number1, ...: series int/float) -> series float

Arguments

NameTypeDefaultDescription
number0, number1, ...const int or const int/float or simple int or simple int/float or input int or input int/float or series int or series int/floatrequiredTwo or more numbers to compare.

Returns

const int or const float or simple int or simple float or input int or input float or series int or series float: the smallest argument.

Remarks

  • math.min(x, cap) limits a value to an upper bound.
  • An na argument makes the result na.

Example

Pine ScriptCap a ratioOpen in editor
//@version=6
indicator("Capped volume ratio")
ratio = volume / ta.sma(volume, 20)
plot(math.min(ratio, 3), "Ratio (max 3)", color = color.blue, style = plot.style_histogram)

See also

Runs on Sidechair