Using new ROUND() function giving erratic results?

Hi, I was wondering if anyone has been working with the new ROUND() function released with version 1.4?

I have had success rounding simple formulas like CLOSE()/OPEN() but have not had much luck with more complex formulas, for example:

BARDATE()/7 + MOD(VALUE=30, 19 * MOD(VALUE=19, YEARNUM()) - 7) * 0.14;

I've tested this formula using two custom labels on the cursor, the first label using the ROUND function as follows:

testdate = BARDATE()/7 + MOD(VALUE=30,19*MOD(VALUE=19,YEARNUM())-7) * 0.14;

v1 = ROUND(testdate, DECIMALTYPE=0.00) ;


and the second label not using the ROUND function at all as follows:

testdate = BARDATE()/7 + MOD(VALUE=30,19*MOD(VALUE=19,YEARNUM())-7) * 0.14;


With the cursor hovering over 12 April 2019 (BARDATE()=43567), both custom labels return 6227.777143. I would have expected that the label using the ROUND function should have returned a value of 6227.780000.

However, if I substitute the testdate variable with a simple formula like CLOSE()/OPEN(), the two custom labels return values as expected. For example, on the daily SPY (WI) on 12 April 2019, the custom label using ROUND returns 1.000000 while the custom label not using ROUND returns 1.002258.

Has anyone had a similar experience or can give me a clue on what I have missed?

Many thanks


For what it is worth, I was able to get expected rounding results by using the following script (using FLOOR and MOD functions) as a substitute for the ROUND function

testdate = BARDATE()/7 + MOD(VALUE=30,19*MOD(VALUE=19,YEARNUM())-7) * 0.14;

ROUNDtestdate = FLOOR(testdate) + IF(MOD(VALUE=100, testdate*100)/100);


With the cursor hovering on 12 April 2019 (BARDATE()=43567), a custom label with this script returned the expected value of 6227.780000 (the un-rounded value is 6227.777143). Changing the MOD divisor increases or decreases at what decimal place the rounding occurs (e.g. changing to MOD(VALUE=10, testdate*10)/10 will return a result of 6227.800000). To round to an integer, the 2nd line of the script must be slightly different, as follows:

ROUNDtestdate = FLOOR(testdate) +IF(MOD(VALUE=10, testdate*10)/10 > 0.5, 1, 0)

the script then rounds to 6228.000000 as expected.

Luckily, this post in the forum mentions the FLOOR function. FLOOR is not documented in the Formula Functions & General Interface.

Even though this is a viable alternative to the ROUND function, I'd still be interested if anyone can offer advice on getting the ROUND() function to operate as expected.