Исправил установку take profit. Код:
if (OrdersTotal()>0) { for(i=OrdersTotal() -1;i>=0;i--) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) { if(OrderType()==1 && OrderTakeProfit()==0) { double SL_size_sell=OrderStopLoss()-OrderOpenPrice(); double TP_size_sell=SL_size_sell*3; double TP_price_sell=OrderOpenPrice()-TP_size_sell; bool res=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(TP_price_sell,5),0,Blue); if (!res) { Print("Ошибка модификации ордера. Код ошибки=",GetLastError()); } } if (OrderType()==0 && OrderTakeProfit()==0) { double SL_size_buy=OrderOpenPrice()-OrderStopLoss(); double TP_size_buy=SL_size_buy*3; double TP_price_buy=OrderOpenPrice()+TP_size_buy; bool res=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),NormalizeDouble(TP_price_buy,5),0,Blue); if (!res) { Print("Ошибка модификации ордера. Код ошибки=",GetLastError()); } } } }