如何检查工单是否仍然打开或已关闭?
How to check if a ticket is still open or has been closed?
如果我开仓时 OrderSend
设置了 获利 和 止损 ,我如何检查是否它仍然处于打开状态,或者相反,由于 stop_loss 或 止盈?[=11 而关闭=]
您必须具有在发送 OrderSend() 请求时收到的 ticketId。
为了弄清楚交易是否开放,请使用以下内容:
int ticket; //your ticket from OrderSend in global variables
bool isOrderExist(const int _ticket){
if(OrderSelect(_ticket,SELECT_BY_TICKET)){
return(OrderCloseTime()==0);
}else{
int error=GetLastError();
return(error!=4108 && error!=4051);
}
}
为了检查订单是否被 SL 或 TP 或任何其他原因关闭 - 您应该 select 来自 OrdersHistory()
的订单,然后检查评论(通常是 '[sl]'或 '[tp]' 添加到评论)或比较收盘价和 SL 和 TP
您或许还可以使用:OrderPrint()
:
if(OrderSelect(10, SELECT_BY_TICKET)==true)
OrderPrint();
else
Print("OrderSelect failed error code is",GetLastError());
来自 MetaEditor 参考:
Prints information about the selected order in the log in the following format:
ticket number;
open time;
trade operation;
amount of lots;
symbol;
open price;
Stop Loss;
Take Profit;
close time;
close price;
commission;
swap;
profit;
comment;
magic number;
pending order expiration date.
如果我开仓时 OrderSend
设置了 获利 和 止损 ,我如何检查是否它仍然处于打开状态,或者相反,由于 stop_loss 或 止盈?[=11 而关闭=]
您必须具有在发送 OrderSend() 请求时收到的 ticketId。
为了弄清楚交易是否开放,请使用以下内容:
int ticket; //your ticket from OrderSend in global variables
bool isOrderExist(const int _ticket){
if(OrderSelect(_ticket,SELECT_BY_TICKET)){
return(OrderCloseTime()==0);
}else{
int error=GetLastError();
return(error!=4108 && error!=4051);
}
}
为了检查订单是否被 SL 或 TP 或任何其他原因关闭 - 您应该 select 来自 OrdersHistory()
的订单,然后检查评论(通常是 '[sl]'或 '[tp]' 添加到评论)或比较收盘价和 SL 和 TP
您或许还可以使用:OrderPrint()
:
if(OrderSelect(10, SELECT_BY_TICKET)==true)
OrderPrint();
else
Print("OrderSelect failed error code is",GetLastError());
来自 MetaEditor 参考:
Prints information about the selected order in the log in the following format:
ticket number;
open time;
trade operation;
amount of lots;
symbol;
open price;
Stop Loss;
Take Profit;
close time;
close price;
commission;
swap;
profit;
comment;
magic number;
pending order expiration date.