how to find the round numbers

 

HI all, I need to build a control to find this situation

 

If (Bid contains 0.0010 or 0.0090) then (...)

 

For instance bid is 1.3810 or 1.3890. How can I isolate the 10 and 90 round numbers?

 

Thank you!

 

Not sure, maybe something like this will do it?

Odd! SRC won't work with this post for some reason! 

 
 double B=Bid;
 if(Digits==5 ||Digits==4)
    {
    double r=NormalizeDouble(B-(MathFloor(B*100)/100),5);
    if(r==0.0090 || r==0.0010)
      Print("true");
    }
 
  1. GumRai: Odd! SRC won't work with this post for some reason!
    Happens sometimes (JS gets confused.) Copy what you need (the html,) back out of the edit form, control-refresh, edit again.
  2.     double r=NormalizeDouble(B-(MathFloor(B*100)/100),5);
        if(r==0.0090 || r==0.0010)
    
    This fails on JPY where digits < 4. This is also subject to floating equals problems The == operand. - MQL4 forum
  3. int BidPips = int(Bid / pips2dbl) % 100;
    if( BidPips == 90 || BidPips == 10) ...
    
 

WHR your code will introduce a rounding error of 1 pip sometimes too

 
SDC: WHR your code will introduce a rounding error of 1 pip sometimes too
Yep, probably should round to nearest pip
int BidPips = int(Bid / pips2dbl + 0.5) % 100;