Can compiled MT4 programs be called as subroutines and when back in the 'parent program' and then repeat the same thing with a different compiled MT4 program?
Yes, use the #import preprocessor command on code you have previously compiled as a library.
Or, simpler, use the #include preprocessor command to call source from an MQH (header) file
Yes, use the #import preprocessor command on code you have previously compiled as a library.
Or, simpler, use the #include preprocessor command to call source from an MQH (header) file
HI Phy,
Basically I want to automatically add a trailing Stop Loss after a comercial EA has opened a position.
I haven't done ny MQL4 programming as of yet, but will look into your suggestionin a while when I am able to.
Thanks,
DougRH
You probably won't be able to get a commercial EA to call your code.
Just write your own standalone stop manager and attach it to a chart.
HI Phy,
Basically I want to automatically add a trailing Stop Loss after a comercial EA has opened a position.
I haven't done ny MQL4 programming as of yet, but will look into your suggestionin a while when I am able to.
Thanks,
DougRH
You don't even need to have one EA call the other to do this.
1. Attach the commercial EA to the chart in one instance of the MT4 platform, and let it continue to open the orders with 0 stoploss
2. Create another instance of the MT4 platform and have it login to the same broker account
3. Write your own EA which you will attach in the 2nd instance; it will:
- with each tick, enter a loop which selects each order in MODE_TRADES
- if the order has a stoploss of 0, then it will modify the order to set the stoploss to the desired value
CB
You don't even need to have one EA call the other to do this.
1. Attach the commercial EA to the chart in one instance of the MT4 platform, and let it continue to open the orders with 0 stoploss
2. Create another instance of the MT4 platform and have it login to the same broker account
3. Write your own EA which you will attach in the 2nd instance; it will:
- with each tick, enter a loop which selects each order in MODE_TRADES
- if the order has a stoploss of 0, then it will modify the order to set the stoploss to the desired value
CB
Hi PHY & CB,
As I said, I haven't gotten into programming yet, and won't be fore a little while, but I have note of this and will try it ASAP.
I'd jump onboard and have a go at it now as it sounds quiet simple and straight forward, but I have enough experience with programming and the learning curve required to do even basic things, that that isn't the case. I'm very much in a potsition of my life being 'overloaded already right now, but may take a peak at it soon. Though with MT5 being (supposedly) right around teh corner, I have been thinking about waiting untill it is out, as this will probably be more effective and efficient time wise.
Thanks for sharing and the insight (< 8)
Prosperous Trading!
Though with MT5 being (supposedly) right around teh corner, I have been thinking about waiting untill it is out, as this will probably be more effective and efficient time wise.
Thanks for that. I love to start the day with a good laugh.
Seriously though - it would be ridiculous to schedule your trading life around a version change of a programming language. Man up, and get on with it!
CB
You don't even need to have one EA call the other to do this.
1. Attach the commercial EA to the chart in one instance of the MT4 platform, and let it continue to open the orders with 0 stoploss
2. Create another instance of the MT4 platform and have it login to the same broker account
3. Write your own EA which you will attach in the 2nd instance; it will:
- with each tick, enter a loop which selects each order in MODE_TRADES
- if the order has a stoploss of 0, then it will modify the order to set the stoploss to the desired value
CB
Hi Cloud Breaker,
Interesting nickname, I’m wondering about it?
Thanks for responding
It sounds like you have come up with a simple effective solution to this.
Currently I have set up a number of different users specifically to run a number of different instances for different ForEx purposes on one computer. I’m having mixed success with it as they seem to be ‘tripping over each other and getting all tangled up together’. It is possible to just open another instance of the same currency pair in the same MT4 client, though I have found that they both seem to be quite intertwined. Any positions that I open in one currency pair also show up in the other instance of the same currency pair, so at this point in time in spite of it supposed to be able to function properly that at this point in time I ‘m not sure that it works properly under these circumstances and will be investigating this further soon. If I do another installation of the MT 4 platform do you have any suggestions in regards to installing it in the same user account as the original or on one of the other user accounts that I set up specifically for multiple instances of the MT4 platform simultaneously? Ideal, I want to have them on separate computers. I have two PCs and am now on my 32 bit, dual core back up computer as my primary computer that I put together is a 64 bit OS as well as theQuad core CPU that was assembled to take the heavy load and demands of doing CAD-CAM on it. However it is the most unstable computer that I have EVER had in over 30 years of utilizing personal computers: including the early days of windows when one had to reboot it several times a day from it constantly freezing up/crashing )< 8) I haven’t had so many BSoD (Blue Screen of Death) on computers for quite some time, and even at that never as much as this 4x64. I currently have Windows 7 on it, but prior to that I have had both the 32 and 64 bit versions of Vista on it and all have these installations have all had the same problems. Also EVERY time I reboot or shut it off and restart it it loses all of the information about the OS RAID array and I have to utilize the OS disk and repair the start up routine which is a real pain to put it mildly!
It is so unreliable that it is useless. I very recently decided to have one more concerted effort at installing the manufacturer's (MSI) updates before taking them to serious task over it. In my attempts to make it useable, a failed BIOS flashing has left it unable to even start up now: no Video, no POST beep codes of any sort at all. The cooling fans come on and it accesses the CD/DVD drive but other than that nada. I will be holding MSI’s ‘feet to the fire’ over this very soon.
I am most definitely a newbie to this and want to have a go at programming in the upcoming MT5 environment if I am able too as I have a algorithm and methodology in mind that I want to try out. There are quite a number of factors in my life that may not make it feasible for me to do so for quite some time though, if at all.
I’m wondering if you might code and compile this short routine for me and posting the source code and the complied executable program here for me and any others that want/need to utilize it?
Either way, I thank you for your suggestions and I now have a fairly simple method that sounds like it might work to achieve this.
Prosperous Trading
Regards,
DougRH
Regards the username, I work as a commercial helicopter pilot, but due to the economic situation at present my company aren't using the aircraft, so I've been writing EAs for a friend's company in which I have a share.
You're preaching to the choir when you complain about MS Windows. I use a Mac. If my virtual Windows instance bothers me, I treat it with extreme prejudice.
Regarding the code - I tend on this forum to try to help folk learn. So I'm willing to help you as you go about coding it. What I will say is that there is nothing at all special about the routine which requires to be written. Its just a loop which looks (decrementally!!) through the open orders (much like you will find in the codebase for closing orders), decides whether each order it finds is "of interest" and modifies the SL to your configured number of pips away from the open price.
CB
PS - what's with the font? I got 20:20 vision don't you know!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
Can compiled MT4 programs be called as subroutines from another program and when back in the 'parent program' and then repeat the same thing with a different compiled MT4 program?
utilize from the ‘mother’ program? I want to automate Trailing Stop Losses after EAs that I am using.
Thanks to one and all for any & all assistance
Prosperous Trading (< 8)
DougRH