Rounding differences
Forums › ProRealTime English forum › ProRealTime platform support › Rounding differences
- This topic has 4 replies, 2 voices, and was last updated 5 years ago by Nicolas.
-
-
04/13/2019 at 2:56 PM #96349
I found out that there are differences between the rounding of numbers by ProOrder and the same done by ProBuilder.
The following test was made on the indicator “Wilder’s Accumulative Swing Index (ASI)” and the same code turned into a strategy with embedded code, though some slight differences show also if I CALL it.
Indicator:
ASI indicator123456789101112131415161718192021222324252627282930DEFPARAM CalculateOnLastBars = 3000 //commenting this will not work it outdailylimit=1if barindex>0 then//definition SwingIdx parametersAbsHighClose = abs(high - close[1])AbsLowClose = abs(low - close[1])AbsCloseOpen = abs(close[1] - open[1])AbsMaxMin = abs(high-low)CloseClose = close-close[1]CloseOpenToday = close - openCloseOpenYesterday = close[1] - open[1]//computation Kk = max(AbsHighClose,AbsLowClose)//Computation RpartialR = max(AbsHighClose,max(AbsLowClose,AbsMaxMin))if AbsHighClose = partialR thenr= AbsHighClose - 0.5 * AbsLowClose + 0.25 * AbsCloseOpenelser= AbsMaxMin + 0.25 * AbsCloseOpenendifif AbsLowClose=partialR thenr= AbsLowClose-0.5*AbsHighClose+ 0.25 * AbsCloseOpenendif//main formulaif r<>0 thenSwingIdx = 50*(( CloseClose + 0.50 * CloseOpenToday + 0.25 * CloseOpenYesterday ) / R ) *( K / DailyLimit )endifAccumulativeSwingIdx=AccumulativeSwingIdx+SwingIdxendifreturn AccumulativeSwingIdx AS "ASI"Strategy:
ASI strategy123456789101112131415161718192021222324252627282930DailyLimit = 1if BarIndex > 0 then//definition SwingIdx parametersAbsHighClose = abs(high - close[1])AbsLowClose = abs(low - close[1])AbsCloseOpen = abs(close[1] - open[1])AbsMaxMin = abs(high-low)CloseClose = close-close[1]CloseOpenToday = close - openCloseOpenYesterday = close[1] - open[1]//computation Kk = max(AbsHighClose,AbsLowClose)//Computation RpartialR = max(AbsHighClose,max(AbsLowClose,AbsMaxMin))if AbsHighClose = partialR thenr= AbsHighClose - 0.5 * AbsLowClose + 0.25 * AbsCloseOpenelser= AbsMaxMin + 0.25 * AbsCloseOpenendifif AbsLowClose=partialR thenr= AbsLowClose-0.5*AbsHighClose+ 0.25 * AbsCloseOpenendif//main formulaif r<>0 thenSwingIdx = 50*(( CloseClose + 0.50 * CloseOpenToday + 0.25 * CloseOpenYesterday ) / R ) *( K / DailyLimit )endifAccumulativeSwingIdx=AccumulativeSwingIdx+SwingIdxendifgraph AccumulativeSwingIdxbuy at -close limit //dummy linePics outline differences, even when CALLing the indicator, rather than embed it into my strategy.
04/13/2019 at 3:02 PM #96355Inserting this line just after the calculation of SwingIdx worked it out (I multiplied it by 100, rounded to always the lowest integer, then divided it by 100, I just truncated after the 2nd decimal digit) :
patch1SwingIdx = round((SwingIdx * 100) - 0.5) / 100but is not a real solution. Rounding should be always done the same way, no matter whether by ProOrder, ProBuilder, ….
04/13/2019 at 4:17 PM #9635904/15/2019 at 3:05 PM #96518It has been identified and will be fixed in a next update.
3 users thanked author for this post.
07/08/2019 at 4:15 PM #102181I had confirmation today that it has been fixed for IG and PRT software version.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on