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

Questions about MultiCharts and user contributed studies.
samuel
Posts: 4
Joined: Jul 06 2024
Has thanked: 1 time

Jul 08 2024

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?

User avatar
ABC
Posts: 731
Joined: Dec 16 2006
Location: www.abctradinggroup.com
Has thanked: 126 times
Been thanked: 415 times
Contact:

Jul 10 2024

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?

samuel
Posts: 4
Joined: Jul 06 2024
Has thanked: 1 time

Jul 15 2024

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

User avatar
Kate MultiCharts
Posts: 667
Joined: Oct 21 2020
Has thanked: 13 times
Been thanked: 174 times

Aug 01 2024

Hello,

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