Вот нашла у амеров, та же проблема по другому советнику,решение :
#define NO_EXPIRATION 0
order.ticket = OrderSend(Symbol(), order.type, order.lots,
now.open, SlippagePips * pips2points,
0, 0, // order.SL, TP.dscPrt,
reason, myMagic+ot,
NO_EXPIRATION, clr );
if (order.ticket < 0) {
Alert( "OrderSend(type=", order.type, " (", order.type.text,
"), lots=", order.lots,
", price=", DoubleToStr( now.open, Digits ),
" (", DoubleToStr((now.open-Bid)/pips2dbl,Digits.pips),
"), SL=0, TP=0, '", reason, "', ...) failed: ", GetLastError());
RelTradeContext(); // set the trade context free
return(-1);
}
if (!OrderSelect( order.ticket, SELECT_BY_TICKET )) { Alert(
"OrderSelect(",order.ticket, " by ticket) failed: ", GetLastError());
RelTradeContext(); // set the trade context free
return(-1);
}
// IBFX has variable spreads and too much time can pass between
// OrderSend and a following OrderModify without refresh and recomputing
refresh(); // SL.
order.price = OrderOpenPrice(); // Adjust in case of slippage
order.TP = MathMaxDIR( order.TP
, order.price +DIR* minGap.stops
);
order.SL = MathMinDIR( order.SL
, order.price -DIR*(minGap.stops + spread.close)
);
if (!OrderModify( order.ticket, order.price, order.SL,
TP.dscPrt, NO_EXPIRATION, clr )) { Alert(
"OrderModify(ticket=", order.ticket,
", price=", DoubleToStr(order.price, Digits),
" (", DoubleToStr((order.price-Bid)/pips2dbl, Digits.pips),
"), SL=", DoubleToStr(order.SL, Digits),
" (", DoubleToStr((Bid-order.SL)/pips2dbl, Digits.pips),
"), TP=" , DoubleToStr(TP.dscPrt, Digits),
" (", DoubleToStr((TP.dscPrt-Bid)/pips2dbl, Digits.pips),
"), '", reason, "', ...) failed: ", GetLastError(),
", bid=", DoubleToStr(Bid, Digits) );
RelTradeContext(); // set the trade context free
return(-1);
}
Если это правильное решение, то где в коде это вставить?