Download MetaTrader 5
To add comments, please log in or register
Make profit on MQL5 services. It's easy!
cryptex23
268
cryptex23 2014.04.16 18:14 
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.
cryptex23
268
cryptex23 2014.04.16 18:28  
toast:

Try this


That is what i had used initially. didn't work :(
GreenMoney
379
GreenMoney 2014.04.16 18:32  
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.

cryptex23
268
cryptex23 2014.04.16 18:44  
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
/
To add comments, please log in or register