Docs

math.round

Round a series to the nearest whole number.

itm
math.round(x, digits)

Nearest value at digits decimal places, halves away from zero. digits defaults to 0, the nearest integer. The rounding reads the stored binary value, so a decimal half that has no exact binary form, such as 1.005 at 2 places, can round down.

Parameters

A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.

NameKindTypeDefaultRangeDescription
xSeriesnumber--The value to transform.
digitsConstantnumber00 to 10Decimal places to round to (an option, written digits=2). 0 rounds to a whole number.

Output

NameType
valuenumber

Warm-up and missing values

Warm-up
None.
Missing values
na in, na out. A result outside the finite range is a calculation error.

Example

itm
math.round(close)
itm
plot(math.round(close), "Rounded close")