How do I to refresh or update the Expert Advisor when change the .ex4?

 
I'm looking for any solution to refresh or update the Expert Advisor programmatically and automatically whenever change the file .ex4. 

I found a tip to use a GlobalVariables but I do not find any example to do that, by the way, I found this https://book.mql4.com/variables/globals  but it does not works to me or I don't know how to implement it.

I also found this post here https://www.mql5.com/en/forum/159034 where @Fernando Carreiro talk about this, but I still haven't found any example to do that.


How do I can to do that ?
 
If you mean refresh EA on charts without reattaching them or reopening platform you only need to right click on navigation panel and click on Refresh after changed the ex4 file.

Ps. Keep on mind that if you changed numbers of input variables them will be reinitialized to their default values.
 
Fabio Cavalloni:
If you mean refresh EA on charts without reattaching them or reopening platform you only need to right click on navigation panel and click on Refresh after changed the ex4 file.

Ps. Keep on mind that if you changed numbers of input variables them will be reinitialized to their default values.

No @Fabio Cavalloni no! I don't want to refresh the chart, I want to refresh/update the EA I mean. For example, I have an EA version 1.0 and when I change it to 1.1 just coping to folder ...\MQL4\Experts  of terminal I would like it refresh/update on MT4 automatically even it running at the same time. 

@Fernando Carreiro said about this, that it is possible using GlobalVariables of Terminal, but I don't know how could I do this and I do not find any example.

 
Please explain what do you mean for refresh/update because it seems exactly what I wrote and what you can do with procedure in my previous post.
 
Fernando Paiva:

No @Fabio Cavalloni no! I don't want to refresh the chart, I want to refresh/update the EA I mean. For example, I have an EA version 1.0 and when I change it to 1.1 just coping to folder ...\MQL4\Experts  of terminal I would like it refresh/update on MT4 automatically even it running at the same time. 

@Fernando Carreiro said about this, that it is possible using GlobalVariables of Terminal, but I don't know how could I do this and I do not find any example.

No, my post has nothing to do with "updating" a running EA with a new version of the code. My post is about storing its internal data which can be used when the EA is restarted, with the same version or a new version of the code.

What you are asking is for the old version of the EA to stop running and for it to be reattached with the new updated compiled code! I've never done that automatically, and only done that manually!

EDIT: You could probably do that via Win32 API messaging to control the MetaTrader interface to remove and reattach the EA. Alternatively, use the simpler "Apply Template" functionality, as that does not require Win32 API and only standard MQL code.

EDIT2: If you compile via the MetaEditor directly and not copy the file from outside of MetaTrader, then it will be automatically restarted.

 
Fernando Carreiro:

No, my post has nothing to do with "updating" a running EA with a new version of the code. My post is about storing its internal data which can be used when the EA is restarted, with the same version or a new version of the code.

What you are asking is for the old version of the EA to stop running and for it to be reattached with the new updated compiled code! I've never done that automatically, and only done that manually!

EDIT: You could probably do that via Win32 API messaging to control the MT4 interface to remove and reattach the EA. Alternatively, use the simpler "Apply Template" functionality, as that does not require Win32 API and only standard MQL code.

No API, no template.
Right click on navigation panel, refresh and all indicators and EA attached to graphs are automatically updated.
 
Fabio Cavalloni: No API, no template. Right click on navigation panel, refresh and all indicators and EA attached to graph are automatically updated.

Correct, but I believe he wants this done automatically, whenever a new version of the file is placed. He probably wants some monitoring to be done and when an update is placed for it to be automatically restarted.

EDIT: And he probable does not want to restart EVERY chart, indicator and EA all a once but only the affected EA.

EDIT2: As he stated ... "update the Expert Advisor programmatically and automatically whenever change the file .ex4. "

 
Fernando Carreiro:

Correct, but I believe he wants this done automatically, whenever a new version of the file is placed. He probable wants some monitoring to be done and when an update is placed for it to be automatically restarted.

EDIT: And he probable does not want to restart EVERY chart, indicator and EA all a once but only the affected EA.

Indicators and EA that are not changed are not reinitialized...
 
Fabio Cavalloni: Indicators and EA that are not changed are not reinitialized...

I repeat, he does not want to it manually but rather and I quote ...  "update the Expert Advisor programmatically and automatically whenever change the file .ex4. "

EDIT: However, he can combine your suggestion of Right-Click Navigation and do a Refresh with the Win32 API messaging to accomplish that.

 
Fernando Carreiro:

I repeat, he does not want to it manually but rather and I quote ...  "update the Expert Advisor programmatically and automatically whenever change the file .ex4. "

It means save in global variables all last modified date of loaded indicators and EA files and check when they changed from saved value triggering a keyboard command.
Theorically it can be done.
 
Fernando Carreiro:
Correct, but I believe he wants this done automatically, whenever a new version of the file is placed. He probable wants some monitoring to be done and when an update is placed for it to be automatically restarted.

@Fabio Cavalloni I don't want to right click on EA menu on left side and then click to update after copy a file. I don't want to close/open the MT4 to it make the update/refresh the new file. I just wanna to force the MT4 reload the *.ex4.

If I need to do some critical bug fix I will do this manually but sometimes I did a little change and to me don't have any sense to do that even 'cause I have 50 MT4 running because I have 50 accounts to trade, so, think about to refresh/update 50 ex4 manually. Now you know why I want to do that.

I created a Java programa to copy the files to each folder, but now I want that MT4 refresh/update the *.ex4 automatically. 

Are there no way to force the MT4 refresh/update/reload or even read again the *.ex4 and then it works as the new file ? @Fernando Carreiro

Reason: