Is This Code Correct ?

Jean Francois Le Bas  


I just figured out the way to properly test if orders were closed the right way, but i'm wondering if the code is correct (because it accounts for situations when there are requotes and I can't simulate that)

and what could be done to improve the code ?

thanks so much

#define numRetriesOrder 5
bool CloseAll()
   uint retcode = 0;
   int nRetries = numRetriesOrder;         
   while (retcode != TRADE_RETCODE_DONE && nRetries > -1)
      if (nRetries < numRetriesOrder)
   if (retcode == TRADE_RETCODE_DONE)
      return true;
   return false;

void CloseAll(CTrade& myTrade)
   ulong ticket;
   bool ret = false;
   int total = PositionsTotal();
   for(int j=total-1;j>=0;j--)
      if ((ticket=PositionGetTicket(j))>0)
         if (PositionGetInteger(POSITION_MAGIC) == Magic)


Vladimir Karputov  
Never use 'while' and 'Sleep' - you have to beat your hands for that.