22.02.21
|
Mitglied
|
|
Registriert seit: Sep 2011
Beiträge: 55
|
|
Fehler im Programm "Closing multiple positions according FIFO rule"
Hi,
Code:
int ClosePositions(string symbol)
{
int orderstotal = OrdersTotal();
int orders = 0;
int ordticket[100][2];
for (int i = 0; i < orderstotal; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
if (OrderMagicNumber() != Expert_Magic || OrderSymbol() != symbol)
continue;
int orderType = OrderType();
if (orderType != OP_BUY && orderType != OP_SELL)
continue;
ordticket[orders][0] = OrderOpenTime(); // casting of datetime -> int, should work fine...
ordticket[orders][1] = OrderTicket();
orders++;
}
ArrayResize(ordticket,orders); // we have to remove rest of array otherwise it's contents will be sorted as well
ArraySort(ordticket); // sorts ascending by first dimension -> by OrderOpenTime()
for (i = 0; i < orders; i++)
ClosePositionByTicket(ordticket[i][1]);
}
Ich bekomme folgende Fehler angezeigt:
- im Metaeditor : "possible loss of data due to type conversion"
- im Strategietester : "incorrect start position 0 for ArraySort function"
Wie kann man die Fehler beheben ?
Danke!
|