Error 4108

 
t=total-1;
  for (t;t>=0 ;t--)
  {
  OrderSelect(t,SELECT_BY_POS,MODE_TRADES);
  if (OrderType()<2 )
  {
  quant=OrderLots();
  if (OrderType()==0) ///buy
  {
  OrderClose(t,quant,Bid,60,clrNONE);
  }
  if (OrderType()==1) //sell
  {
  bool res1=OrderClose(t,quant,Ask,60,clrNONE);
  if(!res1)
   Alert("Error in close. Error code=",GetLastError());
   else
   Alert("Order closed successfully."); 
  }
  }
  }
Can't figure out why do i keep getting 4108 error.
 
toast:

Try this


That is what i had used initially. didn't work :(
 
cryptex:
Can't figure out why do i keep getting 4108 error.


Don't use the position (t) as ticket number in OrderClose() function:

OrderClose(t,quant,Bid,60,clrNONE); // t is not the ticket number

Use OrderTicket() to retrieve ticket number for selected trade.

 
Thirteen:


Don't use the position (t) as ticket number in OrderClose() function:

Use OrderTicket() to retrieve ticket number for selected trade.


thanks a ton :) works like charm
Reason: