Download MetaTrader 5

Help requested on changes to Time[] after build 574.

To add comments, please log in or register
bushTrader
68
bushTrader  

Even though I have been writing code in mql4 for many years, I will have to confess that I am stumped on some of these new changes since build 509.

I have been using a "string name" + Time[index] to name objects on my charts. However, instead of Time[index] giving the number of seconds,

it gives the time in a text. I need the number of seconds like in build 509. Any help would be appreciated greatly.

qjol
3243
qjol  
int time = Time[index];
bushTrader
68
bushTrader  
I tried that and got the following warning; "possible loss of data due to type conversion".
qjol
3243
qjol  
i tried it in both versions (B509 & B604) & gives me the same result (i dont c any loss of data)
bushTrader
68
bushTrader  
I don't see any loss of data either. I just want to write it so that I have no warnings.
qjol
3243
qjol  
long a = Time[index]; //or ulong
qjol
3243
qjol  

int

The size of the int type is 4 bytes (32 bits). The minimal value is -2 147 483 648, the maximal one is 2 147 483 647.

so only in 2038 it will lose data

bushTrader
68
bushTrader  

I'm not yet familiar with long or ulong. These are new to me.

qjol
3243
qjol  
bushTrader:

I'm not yet familiar with long or ulong. These are new to me.


long

The size of the long type is 8 bytes (64 bits). The minimum value is -9 223 372 036 854 775 808, the maximum value is 9 223 372 036 854 775 807.

ulong

The ulong type also occupies 8 bytes and can store values from 0 to 18 446 744 073 709 551 615.



whatever, this is the solution, (no warnings no errors)

bushTrader
68
bushTrader  
Many thanks, your right, it works, though I'm not sure why yet. I'll study the MQL4 Reference some more.
Simon Gniadkowski
Moderator
18003
Simon Gniadkowski  
bushTrader:
Many thanks, your right, it works, though I'm not sure why yet. I'll study the MQL4 Reference some more.


Do it properly, use the correct variable type . . .

datetime a = Time[index]; 
12
To add comments, please log in or register