Calculating open orders

Back to topics list To post a new topic, please log in or register
avatar
120
DeanDeV 2015.09.14 21: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);
  }

 

avatar
Moderator
3404
GumRai 2015.09.14 22:08 #
 
for(int b=OrdersTotal()-1; b>=0; b--)
You are not checking the order with the index 0
avatar
120
DeanDeV 2015.09.14 22:20 #
 
GumRai:
You are not checking the order with the index 0
Wow! Haha, thanks! I was so flabbergasted by it. Thank you again. 
Back to topics list  

To add comments, please log in or register