Skip to main content

math.round#

Round value to the given number of decimal places.

SYNTAX#

function math.round(value: number, decimals?: number): number

ARGUMENTS#

  • value (number) — Value to round.
  • decimals (number) — Number of decimals to keep. Defaults to 0.

RETURNS#

number — the rounded value.

REMARKS#

For rounding to an exchange's tick increment, use Math.round(value / ctx.tickSize) * ctx.tickSize instead — decimals is base-10 only.

EXAMPLE#

const display = math.round(candles[i].close, 2);
plot('close', display);

SEE ALSO#

math.clamp, chart.tickSize