Download MetaTrader 5
To add comments, please log in or register
Deposit to your account via Visa QIWI Wallet
DeanDeV
330
DeanDeV 2015.09.14 19:13 

Hey guys,

I have written a for loop that returns whether there are any open orders, however, it returns, on occasion, no open orders even when there are open orders. Is there any way to make this more accurate? Below is my code, any help is appreciated.

int OpenOrdersThisPair(string pair)
  {
   int total=0;
   
   for(int b=OrdersTotal()-1; b>0; b--)
    {
     if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
      if(OrderSymbol()==pair) total++;
    }
     return(total);
  }
Keith Watford
Moderator
7950
Keith Watford 2015.09.14 20:08  
for(int b=OrdersTotal()-1; b>=0; b--)
You are not checking the order with the index 0
DeanDeV
330
DeanDeV 2015.09.14 20:20  
GumRai:
You are not checking the order with the index 0
Wow! Haha, thanks! I was so flabbergasted by it. Thank you again. 
/
To add comments, please log in or register