''Stealthy' Dual Stop Loss' Module required.

 

The stealthy, active & functional Stop Loss utilized will only be calculated internally in the EA and then close the order when this is level is reached.

But the second 'published' SL is a 'FailSafe' that is placed on the server when the order is activated. This gets around the problem that is often encountered with the broker having a (much) larger SL than one wishes to utilize. It also provides provides some Fail Safe 'Limit insurance' if the terminal is disconnected from the server.

Both of these SL should be adjustable External Variables.

This should be a very flexible and universal MQL4 'module' that can be utilized repeatedly in many EAs. Perhaps as an 'included' file? I'll let more experienced and knowledgeable folks decide upon the wisdom of it being an included file. Perhaps have both available?



 

It's more a philosophical approach rather than 'this is the way it must be done'

I have done mine via include files (I took the path of least resistance - read on)
- one for the 'header/global' stuff (this includes extern variables)
- one for actual code, including a setup function called from the init()

I started by coding and testing the routines in an EA, then progressively putting them in the include books for other EAs. The downside is that I have to recompile my EAs to use latest code, so there is merit in using libraries (although there is then the issue of getting the extern values into the library).

Ideally, I expect that include files which are just 'smart stubs' calling library functions (that do the actual calcs & work) is perhaps the best compromise.

My 2c worth

 

Hi,

From what I understand, 'Included' files run faster than 'library' files.

I'm not a MQL4 programmer. Thus I am looking for someone that will do this for the benefit to all, including the programmer, myself and preferably post the code here for others to utilize this as well.

Thanks

 
FourX:

Hi,

From what I understand, 'Included' files run faster than 'library' files.

I'm not a MQL4 programmer. Thus I am looking for someone that will do this for the benefit to all, including the programmer, myself and preferably post the code here for others to utilize this as well.

Thanks



include file you can put some sorcecode you will use in different eas. When compile, the include file is included in the .ex4 file already.

library is an external file an the functions inside will called on runtime by ea. This is diffrent and maybe - depends on kibrary and hardware - more slow ... few micro-seconds ... ;-)

 

Hi FourX



I am a new programmer, and have been wanting to do the very same thing you are talking about - that is to calculate stoplosses and trailing stops internal to the EA, and then Closing the position when these internal calculations have triggered a sale. Would you mind sharing the code portion related to doing this? Also, with my own attempt at doing this, I run into the problem that OrderOpenPrice returns a four decimal point value, whereas my stoploss and trailingstops calculations are relying on five decimal accuracy. DoubleNormalize does not return the fifth decimal. DoubletoStr function will allow me to print the actual fifth decimal place for OrderOpenPrice, but now that it's a string, I can't calculate with it and compare it to my stoplosses. Any ideas?


-Andre

 


Hi andrenogues,

I'm a NuB and know very little about MQL Programming. A search here will fins you a number of relevant pages. One is a thttps://www.mql5.com/en/forum/122889 Their is another one here that is more sophisticated one that is supposed to preserve more profits than other dual TSL but I can't find it at the moment. If I find either the WebPage here or the actual code on my computer I'll UpLoad it for you.

For a 2 stage Trail Stop Loss, I use the commercial EA PBTS that does this job effectively and is only ~ $10.. It can be found at http://PipBoxer.Com/

However I am still interested in finding the MQL code as well as I may have occasion to use once in a while. Thus if you find code here that does this, please pass the info along to me and others.

The best of luck with this.

Reason: