下载MetaTrader 5
要添加评论,请登录注册
创建论坛主题并提高您的等级
hualwh
228
hualwh 2008.09.05 04:50 

用 orderselect by pos 选择历史单的顺序是按tik 号排序,能不能按单子的平仓时间排序 ?

for (int i=0;i<OrdersHistoryTotal() ;i++)

OrderSelect(i, SELECT_BY_POS,MODE_HISTORY);

这个用法的选择顺序是按tick的大小排序的,能不能按单子的结束时间排序,让先平仓的单子被选到?

Rashid Umarov
管理员
6599
Rashid Umarov 2008.09.05 07:05  
Create an array and copy into one the order list. Then sort this array as you want.
hualwh
228
hualwh 2008.09.05 11:03  

这样实现不了呀,一维数组排序,如何将ticket 与 orderclosetime 对应起来?

mq4支持多维排序吗?

Rashid Umarov
管理员
6599
Rashid Umarov 2008.09.08 06:37  

See sample

//+------------------------------------------------------------------+
//| returns sorted by TimeClose array of tickets                     |
//+------------------------------------------------------------------+
int LoadSortedTickets(int & Tickets[])
{
int i,counter;
int TicketAndTime[][2];
//----
ArrayResize(TicketAndTime,OrdersHistoryTotal());
 
for (i=0;i<OrdersHistoryTotal();i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
{
if (OrderType()<=OP_SELL)
{
TicketAndTime[counter][0]=OrderCloseTime();
TicketAndTime[counter][1]=OrderTicket();
counter++;
}
}
}
ArrayResize(TicketAndTime,counter);
ArrayResize(Tickets,counter);
ArraySort(TicketAndTime);
for (i=0;i<counter;i++)
{
Tickets[i]=TicketAndTime[i][1];
}
int err=GetLastError();
 
//----
return(counter);
}
/
要添加评论,请登录注册