我收到定单发送错误138,无论是买还是卖,但仅在回测中而不在实时演示中。我尝试调整滑点无济于事。有谁知道怎么了?
double price = iClose(Symbol(), PERIOD_H1, 1);
if (up > down && up > sideway){
double stoploss = NormalizeDouble(price-piploss*Point, Digits);
double takeprofit = NormalizeDouble(price+pipgain*Point, Digits);
int ticket = OrderSend(Symbol(), OP_BUY, 1, price, 5, stoploss, takeprofit, "buy", 16384, 0, clrGreen);
if (ticket<0){
Print("Order send error: ", GetLastError());
} else{
Print("Order success");
}
} else if (down > up && down > sideway) {
double stoploss = NormalizeDouble(price+piploss*Point, Digits);
double takeprofit = NormalizeDouble(price-pipgain*Point, Digits);
int ticket = OrderSend(Symbol(), OP_SELL, 1, price, 5, stoploss, takeprofit, "sell", 16384, 0, clrGreen);
if (ticket<0){
Print("Order send error: ", GetLastError());
} else{
Print("Order success");
}
} else {
Print("sideway");
}
}
答案 0 :(得分:0)
您的价格接近上一个H1蜡烛。可能您之前做过开酒吧检查。无论如何,您的计算可能要花费一些时间,因此强烈建议在发送订单之前建议RefreshRates()
。接下来,您应在发送市场订单时使用常量Ask
和Bid
,它们在刷新汇率后会更新。否则,您会收到其他错误(133、136、138)。