Can i define/change trailling stop using mql4

 

Hi guys,

 

There are a way to define and change trailling stop manually via mql4 code ? 

 

I need to put the trailling stop on orders created on my EA.

 
I've used this kind of thing before.....

      
      if(Bid <= trailingStop){ 
           // stop triggered      
          OrderClose( ticketId, OrderLots(), Bid, slip)
            
      }else if (Bid > high) { 
            // new high set, move stop up
            high = Bid;
           trailingStop = high - stopDist;
       }

and that would run on every tick. There is a bit more you'll add in  to confirm orders for example and you obviously also have to set the stop levels initially when you open a position but that's it in a nutshell.

 
t1m0thy:
I've used this kind of thing before.....

      
      if(Bid <= trailingStop){ 
           // stop triggered      
          OrderClose( ticketId, OrderLots(), Bid, slip)
            
      }else if (Bid > high) { 
            // new high set, move stop up
            high = Bid;
           trailingStop = high - stopDist;
       }

and that would run on every tick. There is a bit more you'll add in  to confirm orders for example and you obviously also have to set the stop levels initially when you open a position but that's it in a nutshell.

Thanks T1m0thy, but this is a hard-coded implementation and works... but i am seeking for a way to use mql4 to activate the trailing stop resource mt4 native just lik we do manually on the image below:

Trailling 

Reason: