Page 1 of 1

There is a problem with the IntPortion in calctime func

Posted: Jul 08 2024
by samuel
I found that calctime(0845, 15) is not equal to 0900, so I tried to find out the issue.

built-in native code in calctime():

Code: Select all

inputs: RefTime( numericsimple ), MinuteChange( numericsimple ) ; CalcTime = MinutesToTime( TimeToMinutes( RefTime ) + MinuteChange ) ;
Here's the function used by calctime() function, and i did some test:

Code: Select all

once begin print(TimeToMinutes(0845)+15, MinutesToTime(TimeToMinutes(0845)+15), MinutesToTime(540)); end;
The output is:
540.00 860.00 900.00
MinutesToTime(TimeToMinutes(0845)+15) gets 8 hours and 60 minutes instead of 9 hours.
I found the problem is within MinutesToTime(), then I dig in and tried the following code:

Code: Select all

variables: var0( 0 ), var1( 1 / 60 ), var2( 0 ) ,var3( 0 ), var4( 0 ); once begin var4 = TimeToMinutes(0845)+15; print(var4 * var1); print(IntPortion( var4 * var1 )); end;
The output is:
9.00
8.00

it seems a issue of IntPortion()

i had installed MC14 R10

i try to downgrading mc version from R10 to R4, but R4 can't duplicate this issue...

Is there a technician here who can explain this?

Re: There is a problem with the IntPortion in calctime func

Posted: Jul 10 2024
by ABC
Hi Samuel,

this is likely caused by the precision of variables of type double. While you expect passing an input parameter of 540 to the function, MC might internally "see" this as 539.999999999999886. Based on that, the result you are receiving when using Intportion is expected.
It would be great to receive a comment from Multicharts and they should adjust all built-in functions that could suffer from this.
As a temporary workaround rounding your inputs to 0 can help in preventing the issue i.e. MinutesToTime(Round(TimeToMinutes(0845)+15, 0)) gives you the result you are after.

Regards,

ABC

I found that calctime(0845, 15) is not equal to 0900, so I tried to find out the issue.

built-in native code in calctime():

Code: Select all

inputs: RefTime( numericsimple ), MinuteChange( numericsimple ) ; CalcTime = MinutesToTime( TimeToMinutes( RefTime ) + MinuteChange ) ;
Here's the function used by calctime() function, and i did some test:

Code: Select all

once begin print(TimeToMinutes(0845)+15, MinutesToTime(TimeToMinutes(0845)+15), MinutesToTime(540)); end;
The output is:
540.00 860.00 900.00
MinutesToTime(TimeToMinutes(0845)+15) gets 8 hours and 60 minutes instead of 9 hours.
I found the problem is within MinutesToTime(), then I dig in and tried the following code:

Code: Select all

variables: var0( 0 ), var1( 1 / 60 ), var2( 0 ) ,var3( 0 ), var4( 0 ); once begin var4 = TimeToMinutes(0845)+15; print(var4 * var1); print(IntPortion( var4 * var1 )); end;
The output is:
9.00
8.00

it seems a issue of IntPortion()

i had installed MC14 R10

i try to downgrading mc version from R10 to R4, but R4 can't duplicate this issue...

Is there a technician here who can explain this?

Re: There is a problem with the IntPortion in calctime func

Posted: Jul 15 2024
by samuel
I encountered the issue when updating MC from R4 to R10.

I found that some strategies have different performances. ex: netprofit,...etc

Currently, I still have MC R4 installed to avoid this issue

Re: There is a problem with the IntPortion in calctime func  [SOLVED]

Posted: Aug 01 2024
by Kate MultiCharts
Hello,

Our engineers have reproduced the issue and have begun working on a solution to implement it a future release.