if(otype == OP_BUY) if(OrderOpenPrice()>= Bid - TrailingStop || OrderStopLoss () == 0 ) { if(OrderStopLoss() == (OrderOpenPrice() + NormalizeDouble(Bid - TrailingStop*Point,Digits ))) if(Bid - OrderStopLoss() < Bid - OrderStopLoss() + TrailingStep*Point) { if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype) if(OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), 0, 0, Yellow)) Print(" OrderModify Ok!"); else Print(" OrderModify Error!"); } } if(otype == OP_SELL) if(OrderOpenPrice()<= Ask + TrailingStop || OrderStopLoss () == 0 ) { if(OrderStopLoss() == (OrderOpenPrice() - NormalizeDouble(Ask + TrailingStop*Point,Digits ))) if(Ask + OrderStopLoss() < Ask + OrderStopLoss() - TrailingStep*Point) { if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype) if(OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), 0, 0, Yellow)) Print(" OrderModify Ok!"); else Print(" OrderModify Error!"); } } RefreshRates(); }