Can i define/change trailling stop using mql4

Back to topics list To post a new topic, please log in or register
avatar
127
wemersonrv 2015.09.01 20:55
 

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.

avatar
5
t1m0thy 2015.09.01 22:52 #
 
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.

avatar
127
wemersonrv 2015.09.02 01:35 #
 
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 

Back to topics list  

To add comments, please log in or register