roundto(var x, var step): var

Rounds a variable to the closest multiple of a given step width. F.i. roundto(Price,PIP) rounds Price to 1 pip, and roundto(x,1) rounds x to the nearest integer.

round(var x): var

Rounds a variable to the nearest integer.


x - var to be rounded.
step - rounding accuracy.


Rounded value of x.


For rounding x up to the next higher step, use roundto(x+0.5*step, step). For rounding x down to the next lower step, use round(x-0.5*step, step).


Price = roundto(Price,PIP); // round price to the next full pip

See also:

floor, ceil

► latest version online