for(int i = OrdersTotal()-1; i>=0; i--) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))continue; if(!(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)) continue; if(OrderType() != otype) continue; if(OrderType() == OP_BUY) { if(OrderOpenPrice()< Bid - TrailingStop || OrderStopLoss () == 0 ) { if(OrderStopLoss() < (OrderOpenPrice() + NormalizeDouble(Bid - TrailingStop*Point,Digits ))) { SL = Bid - TrailingStop * Point; if(OrderModify(OrderTicket(), OrderOpenPrice(), SL, 0, 0, Yellow)) Print(" OrderModify Ok!"); else Print(" OrderModify Error!"); }