CONDITION NEVER EXECUTES???

 
//+------------------------------------------------------------------+
//|                                                  BEST EXPERT.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   


if(iOpen(NULL,30,0)-iClose(NULL,30,0)==-0.0002)
{
Print("I AM HERE");

}
   return(0);
  }
//+------------------------------------------------------------------+
 

IN THE ABOVE PROGRAM "I AM HERE" IS NEVER PRINTED...


I HAV A ALSO TRIED OPEN[0]-CLOSE[0]==-0.0002..BUT THIS CONDITION NEVER RETURNS TRUE AND PRINT IS NEVER PRINTED..

 
I WANT TO GET CURRENT VALUE OF OPEN AN CLOSE  IN M30 FRAME BAR.IN CURRENT BAR.SOMEBODY HELP
 
double f=MathAbs(iOpen(NULL,30,0)-iClose(NULL,30,0));
Print(f);
double d=0.0002;
if((iOpen(NULL,30,0)-iClose(NULL,30,0))==d)
{
Print("I AM HERE");

}

results on backtesting:-

2012.11.10 17:22:42 2012.11.09 23:59  BEST EXPERT EURUSD,M30: 0.0004

2012.11.10 17:22:42 2012.11.09 23:51  BEST EXPERT EURUSD,M30: 0.0001

2012.11.10 17:22:42 2012.11.09 23:50  BEST EXPERT EURUSD,M30: 0.0002

2012.11.10 17:22:42 2012.11.09 23:50  BEST EXPERT EURUSD,M30: 0.0001

2012.11.10 17:22:42 2012.11.09 23:50  BEST EXPERT EURUSD,M30: 0.0002

2012.11.10 17:22:42 2012.11.09 23:49  BEST EXPERT EURUSD,M30: 0.0001

2012.11.10 17:22:42 2012.11.09 23:48  BEST EXPERT EURUSD,M30: 0

2012.11.10 17:22:42 2012.11.09 23:48  BEST EXPERT EURUSD,M30: 0.0002

but still the print command never executes.. 

 

Please don't double post, especially making a question in 2009 topic, you probably won't get the answer from the poster.

What you doing is comparing double type variable, which is difficult to do. Why don't you print the real value of  iOpen(NULL,30,0)-iClose(NULL,30,0) up to 8 digits after decimal point, and see for your self

double f = iOpen(NULL,30,0)-iClose(NULL,30,0);
Print(DoubleToStr(f, 8));

The solution, you may want to convert the value into integer type.

See also : Can price != price ? and https://www.mql5.com/en/forum/140534