CopyClose And CopyOpen return bad result

To add comments, please log in or register
hyalavi
9
hyalavi  

Hello

CopyClose and CopyOpen return bad result after close and reopen metatrader5

I am comparing two copyclose with same parameters and I receive different result from this functions;

My Code:


double iClose1[1],iClose2[1];

CopyClose(_Symbol,PERIOD_MN1,date,1,iClose1);

CopyClose(_Symbol,PERIOD_MN1,date,1,iClose2);

   

if(iClose1[0] != iClose2[0])

Print("ERROR: ",iClose1[0]," != ",iClose2[0]);

else

Print(iClose1[0]," = ",iClose2[0]);


And this code on open metatrader5 print this result:

2454.0 = 2454.0

ERROR: 9.79818532658781e-312 != 7.138640856869782e-189


Can anyone help me?!

Tanks


Sergey Golubev
Moderator
106140
Sergey Golubev  
8eios
5
8eios  
Same problem here
Carl Schreiber
Moderator
7132
Carl Schreiber  

You have to understand the way double values work, e.g. here!

Two doubles are practically never equal like integers only too close to be different!

if(fabs(iClose1[0]-iClose2[0]) > _Point*0.001) ...
Double-precision floating-point format - Wikipedia
Double-precision floating-point format - Wikipedia
  • en.wikipedia.org
Double-precision floating-point format is a computer number format that occupies 8 bytes (64 bits) in computer memory and represents a wide, dynamic range of values by using a floating point. Double-precision floating-point format usually refers to binary64, as specified by the IEEE 754 standard, not to the 64-bit decimal format decimal64. In...
To add comments, please log in or register