EA is not initialized every other time!

 

When I first run MT4 or first attach the EA to a chart, the EA is loaded and initialized, but after removing the EA by "Close(x)" button of the standard library CAppDialog, the next time I attach it, it is loaded successfully but not initialized and does nothing until I change the time frame or remove the EA by usual way - Right Click > Expert Advisors > Remove - and attach it again.

This is repeated every other time.

No error is reported like "Stack Overflow" or "Global initialization failed".

The MT4 build is 1260.

The behavior is not the same in MT5 and MQL5 version of the EA is not acting this way, it initializes and uninitializes fine.

I have developed this EA, the complied size is now raised to almost 900 KB, it doesn't trade and doesn't care about "AutoTrading" and "Allow live trading". The EA uses CAppDialog, JAson classed along with WinINet functions to send/receive data.

Does anyone have the same experience or hopefully a work around?

Do you think is this something related to Stack?

 

I have done many optimizations, reviewed the code, better managed the variables and memory, even replacing built-in "WebRequest()" function with WinINet functions, but no success.

It still loads successfully but not initialized after the EA is removed by "ExpertRemove()" function.

I believe there's a problem with "ExpertRemove()" function which avoids initiating the EA again!

 
I just realized after removing the EA by "ExpertRemove()", attaching a different EA to chart, for example a simple "MACD Sample" shipped with MT4 installation, is not also initialized!
 
Mohammad Hossein Sadeghi:
I just realized after removing the EA by "ExpertRemove()", attaching a different EA to chart, for example a simple "MACD Sample" shipped with MT4 installation, is not also initialized!
Is your Terminal connected to a broker ? There are such issues when not connected.
 
Alain Verleyen:
Is your Terminal connected to a broker ? There are such issues when not connected.

Yes, it's connected. There might also be same issues at weekend, I'm aware of that.

 
Mohammad Hossein Sadeghi:

Yes, it's connected. There might also be same issues at weekend, I'm aware of that.

The only way to get help is to demonstrate the issue with testcase code.
 
Alain Verleyen:
The only way to get help is to demonstrate the issue with testcase code.

I'm struggling.

Reason: