TrailingStop Move

 
I have an EA that does the same job as the Trailing Stop only with scheduled orders.

It modifying the mobile Stop normally, but the problem is that: Suppose a scheduled purchase order was executed, it goes up 10 pips trailing stop follows the 10 positive pips of the order price, until then perfect the problem is that if the price begins to fall the trailing stop starts back 10 pips negative rather than stay.

Does anyone know what function I can use to lock the stop for him not to come back?

The Code:


while(Bid<OrderTakeProfit()||Bid>OrderStopLoss() )
                    
 { 
                 
    OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(MarketInfo(OrderSymbol(),MODE_BID)-Point*TrailingStop*10,Digits),OrderTakeProfit(),0,Green);
                      
 }
     OrderClose(cnt, OrderLots(), OrderClosePrice(), 0);
     return(0);
               

 

 

 

 

 

Regards, 

Reason: