Sidechair

math.round_to_mintick()

Browse the reference

Rounds a number to the nearest multiple of the symbol's minimum price step.

Try it in the editor

math.round_to_mintick snaps a price to a value the instrument can trade at. For a symbol with a tick of 0.01, 12.3456 becomes 12.35.

Use it before placing a level, a label or an order at a computed price. The result avoids floating-point dust, so three ticks of 0.1 are exactly 0.3.

Syntax

Pine Script
math.round_to_mintick(number: simple int/float) -> simple float
math.round_to_mintick(number: series int/float) -> series float

Arguments

NameTypeDefaultDescription
numbersimple/series int/floatrequiredThe price to snap to the nearest multiple of the symbol's tick size.

Returns

simple/series float: the price rounded to the symbol's tick size.

Remarks

Example

Pine ScriptA tick-aligned targetOpen in editor
//@version=6
indicator("Tick-aligned level", overlay = true)
target = math.round_to_mintick(close * 1.005)
plot(target, "Close + 0.5%", color = color.orange)

See also

Runs on Sidechair