I have an expert advisor running on an instance of Metatrader 4, if I replace the ea's .ex4 file in the expert folder will metatrader get the changes automatically?
I used to right click on the "expert advisors" in the navigator panel and click refresh, hoping metatrader would get the new version of my ea, but the problem was all the settings for the ea were reset.
I was surprised when I saw orders were closed with the wrong stop loss, then I figured out the reason was the settings had been reset when I clicked "refresh".
What's the best way to update a running ea on metatrader4?
Thank you all.
All the best,
It has been discussed here many times, how EA's should implement a recovery mechanism into to be able to function after a failure such as a Crash (or in your case, a replacement of the .EX4 file).
Besides looking over the Order History, some EAs store the information (variables, parameters, states, etc.) in an external data file that is read during the "OnInit()" in order to pick-up where it left off.
Other EAs, use what is called "Global Terminal Variables" that are stored by MetaTrader and can be viewed and changed on the fly from within MetaTrader itself (F3 or Menu -> Tools -> Global Variables):
This way, you can update the .EX4 file and then do a Refresh, and the EA will be re-ininitialised, but since it goes and collects its previous state from the External File or Global Terminal Variables, it can continue with the same parameters and states that it had before.
Thank you for your reply.
When I run my back tests I store the inputs into a .set file, is there a way to read them back in inside the onInit() function?
That way anytime the ea is initialized it would load the correct inputs right?
That is not the same thing. That is just for External Parameters and Inputs only, which can be loaded manually from .set files (either in the Strategy Tester, or when you assign the EA to the chart).
However, an EA has many variables and states that can be important to save in case of failure. You should always implement Recovery Protocols for such an event.
Thank you, that code is hard for me to read.
Right now, I just want the ea to get all the inputs back without having to manually configure it. I stumbled into recovery issues because I used to refresh the ea from the navigator panel and lost all manually configured inputs. I think I'll explore the option of reading a file from the onInit() function.
* Indicators use to do the same thing, now they are always reloaded.