Okay, here's the deal. I have a block of orders I'd like to close all at once using a general closeall in order to comply with FIFO.
Below are two scenarios that I know will close a block of orders at all once, however, does anyone know whether either will close them according to FIFO or not?
Currently I'm using the first scenario for closing out the orders, however, when I check the results tab while backtesting, it shows the last orders are being closing first so, I guess this won't work the way it is. I haven't checked the second scenario yet, so I don't know? Nor do I normally use it this way (mostly for sorting and tagging).
Anyway, I need to know what is the best (or workable) solution for going about do this?
Any ideas?
Thanks!
Below are two scenarios that I know will close a block of orders at all once, however, does anyone know whether either will close them according to FIFO or not?
PHP Code
for(int i=OrdersTotal()-1; i>=0; i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || cmd()>1) continue;
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,CLR_NONE);
}
PHP Code
for(int i=0; i<=OrdersTotal(); i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || cmd()>1) continue;
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,CLR_NONE);
}
Anyway, I need to know what is the best (or workable) solution for going about do this?
Any ideas?
Thanks!