Mql4 Trailing stop problem

 
   //TRAILING BUYS
   for(int P=OrdersTotal()-1; P>=0; P--)

      
          
            if(OrderSelect(P,SELECT_BY_POS,MODE_TRADES)&&OrderType()==OP_BUY&&OrderStopLoss()<OrderOpenPrice()&&(OrderOpenPrice()+Ask)>MaxSL)

              {
               OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+10*_Point,OrderTakeProfit(),0,Gold );
              }

//TRAILING SELLS
  

      
          
            if(OrderSymbol()==Symbol()&&OrderSelect(P,SELECT_BY_POS,MODE_TRADES)&&OrderType()==OP_SELL&&OrderStopLoss()>OrderOpenPrice()&&(OrderOpenPrice()-Bid)>MaxSL)

              {
               OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-10*_Point,OrderTakeProfit(),0,Red);
              }
      
      //MaxSL is the maximum stoploss which abot twice the average of the last 20bars on the current chart

hi guys,

i am new to mql5 and i'm trying to apply trailing stop to my trades but the code i have only works for buy trades and even that's got a problem of moving the  trailing stop immediately the price moves like a point in profit which is not what i want it to do . below is the code, someone should kindly help.

Moving Average - Trend Indicators - MetaTrader 5 Help
Moving Average - Trend Indicators - MetaTrader 5 Help
  • www.metatrader5.com
The Moving Average Technical Indicator shows the mean instrument price value for a certain period of time. When one calculates the moving average...
 
A price plus a price is meaningless.