对于MT4,MQL
当sendOrder()
时,
有时成功或失败有时主要是由于打滑。
我想在sendOrder()
时获得真实的滑点。
有可能吗?
我现在的源代码如下。
Ticket = OrderSend(_Symbol,OP_SELL, Lot,Bid,2, // '2' is slippage alloable limit.
SL,TP,comment,Magic);
if (Ticket > 0){
// if slippage is under 2 it works.
// want to check the real slippage
}
else {
int err = GetLastError();
if(err == ERR_NO_ERROR ||
err == ERR_COMMON_ERROR ||
err == ERR_SERVER_BUSY ||
err == ERR_NO_CONNECTION ||
err == ERR_TRADE_TIMEOUT ||
err == ERR_INVALID_PRICE ||
err == ERR_PRICE_CHANGED ||
err == ERR_OFF_QUOTES ||
err == ERR_BROKER_BUSY ||
err == ERR_REQUOTE ||
err == ERR_TRADE_CONTEXT_BUSY){
//want to check the slippage here!!!
}
}
答案 0 :(得分:1)
您必须通过与订单一起发送的价格减去OrderOpenPrice来自行计算滑点。
示例:
double price = Bid;
double slippage = 0.0;
int ticket = OrderSend(_Symbol, OP_SELL, Lot, price, 2, SL, TP, comment, Magic);
if(OrderSelect(ticket, SELECT_BY_TICKET))
slippage = int(NormalizeDouble(fabs(price - OrderOpenPrice()) / _Point, 0));