finally have working trailing stop however it has a small error

 
  int TrailingStop=20;

   if(TrailingStop>0)
     { 
     for(int x=0;x<OrdersTotal();x++){
    if(OrderSelect(x,SELECT_BY_POS)==True)
     
    
      if(Ask-OrderOpenPrice()>Point*TrailingStop)
        {
         if(OrderStopLoss()<Ask-Point*TrailingStop)
           {
            bool res=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-Point*TrailingStop,Digits),OrderTakeProfit(),0,Blue);
            if(!res)
               Print("Error in OrderModify. Error code=",GetLastError());
            else
             Print("Order modified successfully.");
           }
        }
     }
     }

for some reason most orders are modified correctly however some orders get modified straight into a loss, for example 

trailing stop for order one: move negatively for 18 points. 2 points left 

order 2 placed

order 2 trailingstop can only move 2 points but its just been placed. 

Maybe im just misunderstanding. 

 
int TrailingStop=20;
//
if(Ask-OrderOpenPrice()>Point*TrailingStop)

For most instruments you will be trailing by 2 pips. Is that what you want?

Reason: