void Trailing() { trailing_stop = 500; for(int i = (OrdersTotal() - 1); i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true) { if (OrderSymbol() == Symbol()) { if ((OrderType() == OP_BUY)) { if(Bid - OrderOpenPrice() > NormalizeDouble(trailing_stop*Point,Digits)) { double SL = NormalizeDouble(OrderOpenPrice()+1*Point,Digits); if (OrderStopLoss() != SL) { Alert(SL); bool Ans=OrderModify(OrderTicket(),OrderOpenPrice(),SL,OrderTakeProfit(),0); } } } if (OrderType() == OP_SELL) //Если цена ушла на trailing_stop пунктов вниз - делаем безубыток { if(OrderOpenPrice() - Ask > NormalizeDouble(trailing_stop*Point,Digits)) { Alert("Попали в 1 условие"); Alert("Попали во 2 условие"); SL = NormalizeDouble(OrderOpenPrice()+1*Point,Digits); if (OrderStopLoss() != SL) { Alert("Попали в модифи"); Ans=OrderModify (OrderTicket(),OrderOpenPrice(),SL,OrderTakeProfit(),0); } } } } } } }