Ei there programming guring wish you could help me with this code. Im using this one to close the open orders, it does work when I have only 1 trade open, but when I have 2 trades it only close one, and gives the "Order delete error 4108". Anyone has an idea of what to do?
for (int i=1; i<=OrdersTotal(); i++) //Cycle for all orders..
{ //displayed in the terminal
if(OrderSelect(i-1,SELECT_BY_POS)==true)//If there is the next one
{
Alert("HA ENTRADO OrderTicket 0 ", OrderTicket());
if (OrderType()==OP_BUY)
{OrderClose(OrderTicket(),OrderLots(),Bid,25);}
if (OrderType()==OP_SELL)
{OrderClose(OrderTicket(),OrderLots(),Ask,25);}
}
}
for (int i=1; i<=OrdersTotal(); i++) //Cycle for all orders..
{ //displayed in the terminal
if(OrderSelect(i-1,SELECT_BY_POS)==true)//If there is the next one
{
Alert("HA ENTRADO OrderTicket 0 ", OrderTicket());
if (OrderType()==OP_BUY)
{OrderClose(OrderTicket(),OrderLots(),Bid,25);}
if (OrderType()==OP_SELL)
{OrderClose(OrderTicket(),OrderLots(),Ask,25);}
}
}
Greetings, BeLikewater