When using variables instead of values, coding doesn't work!!

 

In this code snippet, Instead of BuyLots*1, BuyLots*3,BuyLots*9, if i use digits like 0.1,0.3,0.9 respectively. The code works, if not the the below code does not work. can anyone point out what wrong i have done in this code??



   extern double SellLots = 0.1;
   extern double BuyLots = 0.1;
 

 
    bool exists3 = false;
    bool exists4 = false;
    bool exists5 = false;
    bool exists6 = false;
    for (int i=OrdersTotal()-1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
        if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
        {
            exists3 = true;
        }
        if (OrderType() == OP_SELLSTOP && OrderLots() ==SellLots*1 && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
        {
            exists4 = true;
        }
         if (OrderType() == OP_SELLSTOP && OrderLots() ==SellLots*9 && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
        {
            exists5 = true;
        }
          if (OrderType() == OP_SELLSTOP && OrderLots() ==SellLots*27 && OrderSymbol() == Symbol() && OrderMagicNumber() == 1)
        {
            exists6 = true;
        }
    }
  
    
     if (exists3 && OrderLots() == BuyLots*1 && exists4)
    {
        DeletePendingOrder();
        SellPendingOrder(SellLots*3,SellTakeprofit*2);
    }   
      else if(exists3 && OrderLots() == BuyLots*3 && !exists5)
   
    {
      SellPendingOrder(SellLots*9,SellTakeprofit*3);  
        
    }
      else if(exists3 && OrderLots() == BuyLots*9 && !exists6)
   
    {
      SellPendingOrder(SellLots*27,SellTakeprofit*4);  
        
    }
 
 
kmnatarajan:

yeah thanks dude....


So, what's the alternative for that??
Read the threads, there are many options to correctly compare double variables/values.
 
hmmm, i got an alternative idea for that and now is working...i converted them to integer by multiplying them with some 100s, and stored in integer variables, then compared them.... thanks dudes..
 
kmnatarajan:
hmmm, i got an alternative idea for that and now is working...i converted them to integer by multiplying them with some 100s, and stored in integer variables, then compared them.... thanks dudes..
You mean like this ? https://www.mql5.com/en/forum/140534
 
yeah, similar to the likes of it...i solved the issue...thanks..
Reason: