Restarting Metatrader Application from EA ?

To add comments, please log in or register
sri darwanto
10
sri darwanto  

dear all,

how i can restarting MetaTrader Application from EA ?

give me the code sample ..


thanks

gordon
2318
gordon  
sridarwanto:

dear all,

how i can restarting MetaTrader Application from EA ?

give me the code sample ..


thanks

Just curious - why would u want that?

And to answer your question - it might be doable via WinAPI calls and some sort of delayed batch to re-launch the Terminal. But it's going to be ugly.

JC
1588
JC  
sridarwanto:

how i can restarting MetaTrader Application from EA ?

give me the code sample ..

Personally, I do it using an external executable. MT4 calls the executable which then shuts down that MT4 instance and restarts it. (I actually use a DLL as the interface between MT4 and the external executable, but that bit isn't absolutely necessary.)


Can't provide the actual code, I'm afraid. But it's perfectly possible. The executable gets given the handle of an MT4 window (i.e. WindowHandle), and the path of the MT4 instance (i.e. TerminalPath). It looks up the process associated with the window handle, closes the window, waits for the associated process to terminate, and then restarts the copy of terminal.exe in the specified path.


You might be able to achieve the same effect with a batch file rather than an executable, but you'd have fun doing the close of MT4, and even more fun detecting when the close had finished and it was therefore okay to restart the MT4 instance.


gordon wrote >>

Just curious - why would u want that?

In our case, it's because there's a weird issue where 2 or 3 out of 20ish accounts with one particular broker periodically lose their connection to the broker, and it doesn't get reinstated unless the instance of MT4 is restarted. (And, no, there's no correlation between the accounts in question and a particular VPS or broker server.) So, we have an automated process which monitors the health of the connection and restarts MT4 if necessary. Beats being woken at 3am by text messages telling me that an instance of MT4 has lost its connection.

sri darwanto
10
sri darwanto  
gordon:

Just curious - why would u want that?

And to answer your question - it might be doable via WinAPI calls and some sort of delayed batch to re-launch the Terminal. But it's going to be ugly.


i need this, because i have an EA that after running this EA sometime i  have to restart the application and i don't know the time this EA need restart but i was give the alert that application need restart.

i want to replace the alert with this tool.

if i have this tool, i can running this EA without control.

thanks

To add comments, please log in or register