Hey guys. . I coded a trailing stop, however it does not get the job done correctly, for Ex, when we've purchase position, and second and first trailing stop activates, if cost goes down, next trailing stop altered its cost and it goes straight back into the original one... that is actually the code, what's wrong with this code, just how should I fix this issue. thanks.

Inserted Code void TrailStops() { double Pointt = Point; If ((Stage == 0.00001) || (Stage == 0.001)) Pointt *= 10; int Mod; Dual sl=OrderStopLoss(); for(int cnt=OrdersTotal()-1;cntgt;=0;cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(BreakEvengt;0) { if(Bid-OrderOpenPrice()gt;Pointt*BreakEven) { if(OrderStopLoss()lt;Bid-Pointt*BreakEven) { if(OrderType()==OP_BUY){ Mod = OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(OrderOpenPrice()-ModifiedStop*Pointt,Digits),OrderTakeProfit(),0,Bl ue); if(! Mod) Publish(Error in OrderModify. Error code{},GetLastError()); else Print(Order modified successfully.) ; } if(OrderType()==OP_SELL){ Mod = OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(OrderOpenPrice() ModifiedStop*Pointt,Digits),OrderTakeProfit(),0,Re d); if(! Mod) Publish(Error in OrderModify. Error code{},GetLastError()); else Print(Order modified successfully.) ; } } } If(Bid-OrderOpenPrice()gt;Pointt*two*BreakEven) { If(OrderStopLoss()lt;Bid-Pointt*two*BreakEven) { if(OrderType()==OP_BUY){ Mod = OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(OrderOpenPrice()-2*ModifiedStop*Pointt,Digits),OrderTakeProfit(),0, Blue); if(! Mod) Publish(Error in OrderModify. Error code{},GetLastError()); else Print(Order modified successfully.) ; } if(OrderType()==OP_SELL){ Mod = OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(OrderOpenPrice() 2*ModifiedStop*Pointt,Digits),OrderTakeProfit(),0, Red); if(! Mod) Publish(Error in OrderModify. Error code{},GetLastError()); else Print(Order modified successfully.) ; } } } } } }