Duplicate orders being sent? - page 3

 
DomGilberto:
I'm actually going through my entire code now and wanted to double check all my loops. I assume this is ok?

It looks OK to me, the only thing you aren't doing that you should iss checking that your OrderSelect() has worked . . . if it hasn't worked your OrderSymbol() call isn't going to return the correct value.


One off topic suggestion . . .

//+----------------------------------------------------------------------------------------------------------------------------------------+  
//| Check to see if any order open on this currency pair                                                                                   |
//+----------------------------------------------------------------------------------------------------------------------------------------+   

int OpenOrdersThisPair(string pair = "") // <-----  changed
  {
   int total=0;

   if(pair = "") pair = Symbol();             // <-----  added
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==pair) total++;
     }
   return(total);
  }

then your . . .

if(OpenOrdersThisPair(Symbol()) > 0)

. . . . can be simplified to . .

if(OpenOrdersThisPair() > 0)

. . . when you are using the chart symbol.

 
Thanks for the heads-up - good tip. :)