ขอบคุณครับได้ล่ะครับไปหาใน Google มา ^^
if (FIFO)
{
// Create an array to hold the tickets of open orders. The following code could
// be changed to that it also includes pending orders.
int TradeList[][2];
int ctTrade = 0;
int i = 0;
// Loop through the list of open orders, adding orders to TradeList if they are filled rather than pending
for (i = 0; i < OrdersTotal(); i++)
{
OrderSelect(i, SELECT_BY_POS);
switch (OrderType())
{
case OP_BUY:
case OP_SELL:
// Resize the array
ctTrade++;
ArrayResize(TradeList, ctTrade);
// Put the open time in [x][0] and the ticket in [x][1]
TradeList[ctTrade - 1][0] = OrderOpenTime();
TradeList[ctTrade - 1][1] = OrderTicket();
break;
default:
// Pending order. Ignore.
break;
}
}
// Sort the array. This sorts on [x][0], therefore ordering the array
// in ascending order of open time. After this [0][0] holds the first open-time,
// and [0][1] holds the corresponding ticket number
ArraySort(TradeList, WHOLE_ARRAY, 0, MODE_ASCEND);
// It's now possible to loop through the array doing something with
// the tickets (and without needing to worry about the effect
// on ctTrade of closing orders etc)
i = 0;
for (i = 0; i < ctTrade; i++)
{
if (OrderSelect(TradeList[i][1], SELECT_BY_TICKET))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
{
RefreshRates();
int ticket = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(OrderClosePrice(), Digits), Slippage, Red);
if (ticket > 0)
{
Print("Order : ", OrderTicket(), " closed by group order take profit : ", TakeProfitPercentage, " % ($", DoubleToStr(val1, 2), " /$", DoubleToStr(gi57640, 2), ")");
}
else Print("Error close order : ", GetLastError());
}
}
}
}