默认情况下 MQL4 订单是如何排序的?
How are MQL4 Orders ordered by default?
在mql4中使用OrderSelect()
时,订单是默认按照票号排序的吗?我的意图是对从第一个打开的订单到最近打开的订单使用 OrderModify()
。
您不能在没有参数的情况下调用 OrderSelect()
函数。您必须指定 ID 和选择订单的方式。如果您知道订单 ID,正如在 MT4 终端 window 中看到的那样,您可以调用 OrderSelect( order_id, SELECT_BY_TICKET)
,如果您不知道或者如果您循环历史交易,则必须应用 OrderSelect(i,SELECT_BY_POS)
或 OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)
其中 i
是介于 0 和 OrdersTotal()
或 OrdersHistoryTotal()
之间的整数。
如果您以 i
作为整数遍历交易数组,强烈建议您从最大值循环到零(反之亦然),您可以通过调用 OrderTicket()
获取票证 ID OrderSelect(*,*[,MODE_HISTORY])
成功后函数。
除非在文档中明确指定,否则切勿假设 MQL 中的任何内容。也就是说,您需要先对票号进行排序,然后再按顺序对其进行迭代。
CArrayInt tickets;
for(int i=0; OrderSelect(i, SELECT_BY_POS); i++)
tickets.Add(OrderTicket());
tickets.Sort();
for(int i=0; i<tickets.Total(); i++)
if(OrderSelect(tickets[i], SELECT_BY_TICKET))
...
`enter code here`
int Magic = 12345;
// This reads the orders LIFO (last in...)
// the index is an integer and is incremented from 0
// as the orders are placed. It is NOT
// the ticket number. No sorting necessary.
for(int i=OrdersTotal()-1;i>=0;i--)
if(_Symbol=OrderSymbol() && Magic = OrderMagicNumber())
if(OrderSelect(i, SELECT_BY_POS) {
Print("Order Index: ",i,", Ticket: ",OrderTicket());
在mql4中使用OrderSelect()
时,订单是默认按照票号排序的吗?我的意图是对从第一个打开的订单到最近打开的订单使用 OrderModify()
。
您不能在没有参数的情况下调用 OrderSelect()
函数。您必须指定 ID 和选择订单的方式。如果您知道订单 ID,正如在 MT4 终端 window 中看到的那样,您可以调用 OrderSelect( order_id, SELECT_BY_TICKET)
,如果您不知道或者如果您循环历史交易,则必须应用 OrderSelect(i,SELECT_BY_POS)
或 OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)
其中 i
是介于 0 和 OrdersTotal()
或 OrdersHistoryTotal()
之间的整数。
如果您以 i
作为整数遍历交易数组,强烈建议您从最大值循环到零(反之亦然),您可以通过调用 OrderTicket()
获取票证 ID OrderSelect(*,*[,MODE_HISTORY])
成功后函数。
除非在文档中明确指定,否则切勿假设 MQL 中的任何内容。也就是说,您需要先对票号进行排序,然后再按顺序对其进行迭代。
CArrayInt tickets;
for(int i=0; OrderSelect(i, SELECT_BY_POS); i++)
tickets.Add(OrderTicket());
tickets.Sort();
for(int i=0; i<tickets.Total(); i++)
if(OrderSelect(tickets[i], SELECT_BY_TICKET))
...
`enter code here`
int Magic = 12345;
// This reads the orders LIFO (last in...)
// the index is an integer and is incremented from 0
// as the orders are placed. It is NOT
// the ticket number. No sorting necessary.
for(int i=OrdersTotal()-1;i>=0;i--)
if(_Symbol=OrderSymbol() && Magic = OrderMagicNumber())
if(OrderSelect(i, SELECT_BY_POS) {
Print("Order Index: ",i,", Ticket: ",OrderTicket());