What will happen to the attached EA if we restart MT4?

 

Hi there,

What would happen to the EA if we restart MT4?

Imagine your EA has the variable "int Status=0;" in global area. Its value may change just in start() function, and now after a week of trading with EA you decide to restart MT4 to prepare for the new week.

Your EA has calculated Status=2 in the last tick of last week.

So if you just restart MT4 and your server but keeping the EA attached, what would be the value for Status? 0 or 2?

Your Advice is appreciated,

Hossein

 
You restart the EA, status=0 as the code specifies.
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.
 
William Roeder:
You restart the EA, status=0 as the code specifies.

Thank you very much William!