include trailing stop

 

Hello everybody,


this user here created a very interesting trailing stop tool. It works fine when, for example, placing it on a chart in the mt4 terminal.

https://www.mql5.com/en/code/9530

Now, I'd like to integrate this functionality, if possible, into an expert adviser I've already programmed for use with the "system tester".

I've never worked with scripts or include files, so I tried to put this file in the "include" folder and inserted into my EA for example

#include <TrailingStopFrCn.mq4> but then there are messages like "start function already defined" I'm sure I made a basic mistake here.

Nevertheless if anybody knows how to simply integrate this trailing function in a EA thanks in advance.

 
fxnew:


Hello everybody,


this user here created a very interesting trailing stop tool. It works fine when, for example, placing it on a chart in the mt4 terminal.

https://www.mql5.com/en/code/9530

Now, I'd like to integrate this functionality, if possible, into an expert adviser I've already programmed for use with the "system tester".

I've never worked with scripts or include files, so I tried to put this file in the "include" folder and inserted into my EA for example

#include <TrailingStopFrCn.mq4> but then there are messages like "start function already defined" I'm sure I made a basic mistake here.

Nevertheless if anybody knows how to simply integrate this trailing function in a EA thanks in advance.

You can simply add the 2 functions in the code in the CodeBase into your EA and have a go at calling them correctly . . . as the error said, you can't have 2 start() function . . . the one in your EA and the one in the CodeBase code.
 

thanks a lot RaptorUK,

I got my custom EA code now with with the function call i.e. int Start () { .... TrailingStop(); ... return(0);} after that comes the function definition of TrailingStop()

now when using in the System Tester (EA) a command (just for testing) like TicketSell=OrderSend(Symbol(),OP_SELL,0.1,Bid,20,NULL,NULL) a position is opened but the TrailingStop function apparently doesn't react/is not triggered whereas placing the original trailing function scipt on a chart it works brilliantly be recognizing automatically any open positions (of that currency!)

so do you have any idea how to get this topic working?

 
fxnew:

thanks a lot RaptorUK,

I got my custom EA code now with with the function call i.e. int Start () { .... TrailingStop(); ... return(0);} after that comes the function definition of TrailingStop()

now when using in the System Tester (EA) a command (just for testing) like TicketSell=OrderSend(Symbol(),OP_SELL,0.1,Bid,20,NULL,NULL) a position is opened but the TrailingStop function apparently doesn't react/is not triggered whereas placing the original trailing function scipt on a chart it works brilliantly be recognizing automatically any open positions (of that currency!)

so do you have any idea how to get this topic working?


Did you create and set the variables that the TrailingStop() function needs to work ? for example, Magic ?
Reason: