Hello I am developing an EA to trade in the market.
I am trying to figure out if there is a way to code into the EA so that when it is running, and suddenly the VPS failed and the EA was disconnected. Would I be able to run it again so that it would continue its task before restarting??
I hope I explain myself in a clear way. Thank you all
Yes, of course you can code an EA to continue after a restart.
The coding depends on the EA as there is not one code that will be correct for all EAs.
EAs must be coded to recover.
If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static/global ticket variables will have been lost. You will have an open order but don't know it, so the EA will never try to close it, trail SL, etc. How are you going to recover? Use a OrderSelect / Position select loop to recover, or persistent storage (GV+flush or files) of ticket numbers required.
On a network disconnection you might get ERR_NO_RESULT or ERR_TRADE_TIMEOUT. There is nothing to be done, but log the error, return and wait for a reconnection and a new tick. Then reevaluate.
Thank you William and Keith for your kind response. I will continue to do more research and will post my questions here
Thank you all so much.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello I am developing an EA to trade in the market.
I am trying to figure out if there is a way to code into the EA so that when it is running, and suddenly the VPS failed and the EA was disconnected. Would I be able to run it again so that it would continue its task before restarting??
I hope I explain myself in a clear way. Thank you all