help, trailing stop keeps bouncing back to stoploss

 

I have an ea which I have been working on which moves the stoploss once trade is initially profitable. I also have a trailing stop. Once the trailing stop is met, it still bounces back to the stoploss. How do I correct the code?


//Close

//+------------------------------------------------------------------+
//| Signal Begin(Exit Sell) |
//+------------------------------------------------------------------+

if (RSI6 <= 35 && Low1M < Lowest1MVal && RSI6 >= RSIarray[minValueIdx]&& Low1M <= M1_support && Low1M <= M1_support1 ) Order = SIGNAL_CLOSESELL;

if (RSI6 <= 35 && Low1M <= Lowest1MVal && RSI6 > RSIarray[minValueIdx]&& Low1M <= M1_support && Low1M <= M1_support1 ) Order = SIGNAL_CLOSESELL;


//+------------------------------------------------------------------+
//| Signal End(Exit Sell) |
//+------------------------------------------------------------------+

if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
Print("7");
OrderModify(OrderTicket(), OrderOpenPrice(), highstop, OrderTakeProfit(), 0, Yellow);
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
//Trailing stop
if(UseTrailingStop && TrailingStop > 0) {
if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) {
if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) {
Print("6");
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, White);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}

//Move stoploss
if(UseStopLoss && StopLoss > 0) {
if(OrderOpenPrice() - Ask >= Point * (TightenStop)) {
if(OrderStopLoss() > Ask + Point * (TightenStop)) {
Print("Tighten Stop",OrderStopLoss());
Print("5");
OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice()+ Point * MoveStop, OrderTakeProfit(), 0, Purple);
Print ("Moved stop to",(OrderOpenPrice()+ Point * MoveStop));
if (!EachTickMode) BarCount = Bars;
continue;

}
}
}

//Move stoploss to Break even
if(UseStopLoss && StopLoss > 0) {
if(OrderOpenPrice() - Ask >= Point * 10) {
if(OrderStopLoss() > Ask + Point * (TightenStop)) {
Print("Tighten Stop to Break even",OrderStopLoss());
OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, Aqua);
Print ("Moved stop to Break even",OrderOpenPrice());
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
}
}
}

 
You are telling it to read the whole program each time you need to add breaks to stop it reading certain parts of the program when it is required