How to Round Up/Down To Nearest Tick in EasyLanguage

This is how you round to the nearest tick in EasyLanguage – helpful when plotting
price based indicators. Also the formula for calculating the min tick value is given.



vars: minTick(0),testPrice(0);

minTick = minMove/priceScale;
testPrice = close * .21 * range;

// round up
value1 = testPrice + (minTick-mod(testPrice,minTick));
// round dn
value2 = testPrice - (mod(testPrice,minTick));

{mod is a call to the modulus function
 aka remainder function -- mod(12,5) = 2 -- 12/5 = 2 Remainder 2
 say ES testPrice = 1123.57
     minTick = .25
     1123.57 + (0.25 - mod(1123.57,0.25)) = 1123.57 + 0.25 - 0.07 = 1123.75}
Please follow and like us:

Leave a Reply