MetaTrader 4 Client Terminal build 604 - page 7

To add comments, please log in or register
graziani
2168
graziani  
sub:
datetime t = ObjectGet(nam, OBJPROP_TIME1); //Will return double instead of the "datetime" type
color c = ObjectGet(nam, OBJPROP_COLOR); //Will return double instead of the "color" type


THE BUG!


Not a bug, more like improper design. This however is normal, and should be used in following way:

datetime t = (datetime) ObjectGet(nam, OBJPROP_TIME1);
color c = (color) ObjectGet(nam, OBJPROP_COLOR);

Learn about casting, read C/C++ literature.

graziani
2168
graziani  

Also you should learn about difference between warnings and errors.

And bear in mind that MT4, is not C, but C like language. Also mql5 (towards which we are migrating) is not a full C++ implementation, but is much closer to C++ then mql4 to C.
So you are now using something which is far more similar to standard C++ then before. But be cautious with the C++ (C is acceptably good now), as there are still too many bugs in implementation.

sub
42
sub  
graziani:

Also you should learn about difference between warnings and errors.

And bear in mind that MT4, is not C, but C like language. Also mql5 (towards which we are migrating) is not a full C++ implementation, but is much closer to C++ then mql4 to C.
So you are now using something which is far more similar to standard C++ then before. But be cautious with the C++ (C is acceptably good now), as there are still too many bugs in implementation.


Well taken, graziani!

However, the casting should have been shown in the MT4 reference example otherwise it is wrong example.

My objective is to make money in the trading and not in the C/C++ programming.

Thanks!

Simon Gniadkowski
17205
Simon Gniadkowski  
sub:

I should add that it shows an error with "property strict" directive: "possible loss of data due to type conversion"

Yes of course, thats why I said . . .

RaptorUK:
Why is it a Bug ? ObjectGet() has always returned a double . . . it can't return something different depending on use, it has a type and it returns that type . . . if you don't like the warning cast it . . .


. . and gave you the code to use. Did you try the code I posted ?
sub
42
sub  
RaptorUK:

Yes of course, thats why I said . . .

. . and gave you the code to use. Did you try the code I posted ?


Yes! It works!

Thanks guys!


It is my first day of conversion from 5.09 to 6.04 so there will be more of the confusion.

So far nothing works.

ydrol
513
ydrol  
RaptorUK:

Yes of course, thats why I said . . .

. . and gave you the code to use. Did you try the code I posted ?


It should work until 2038 . After that it might depend on how accurately doubles store longs internally ? (How many bits are used for the mantissa?)
Sunaley
16
Sunaley  

The EX4(compiled in 509 metaeditor) initializes global variables in build 600 with changing timeframes.
But the same codes EX4 which compiled with the new metaeditor(600) won't.

?
graziani
2168
graziani  

No it doesn't.

The global variables are initialized only once.

To initialize global variables after TF change, initialization code needs to reside inside init()/OnInit().

Sunaley
16
Sunaley  
graziani:

No it doesn't.

The global variables are initialized only once.

To initialize global variables after TF change, initialization code needs to reside inside init()/OnInit().

The codes compiled with build 604 prints 0 1 2 3 after TF changed

The codes compiled with build 509 prints 0 0 0 0....Always 0

#property copyright ""
#property link      ""

int A=0;
int init()
  {
   Print(A);
   A++;
   return(0);
  }
graziani
2168
graziani  

I understood your problem correctly.

But in my experience, this was expected behaviour also before. for that reason, i have all necessary initializations in init().

Perhaps this difference comes from different behaviour of EA and indicator?

To add comments, please log in or register