EA stops trading but is still running?

 

Hi everybody

Can anyone help with this problem. I have seen it on many occassions with different experts. The EA will trade many times on several days then it just stops trading. There are no errors in any of the logs and the EA still has a smiley but it does no more trades. If I restart MT4 and load the EA again it will start trading. Running back tests for the days it didn't trade it takes out trades as expected The main problem is that you can't tell when the EA has decided not to trade anymore. The EA is running continuously for days, well all week really, but after more than 2 days it might decide not to trade. It's like a time bomb. Could there be something in my code that is causing the problem? I'm sure I'm not the only person leaving an EA on continuously so if I have the problem and nobody else does I must be doing something wrong. I do have an equity lock but that comes in when the account has been halved. It isn't the particular computer since I have seen it on 3 different computers. Can anyone help?

Thanks

Paul

 

Ruptor :

I am not sure it’s to do with the code or not there are a couple of things you can do to know the reason though;

1. Once you start the EA make sure there is a smiley face on the top right corner of the chart, if its a not a smiley face then all you to do is click Expert advisor button on the toolbar.

2. in the terminal window go to the experts tab and check if there is a message like this 2008.02.13 06:54:55 afterLower EURUSD,M1: uninit reason 1

if so then go to this page https://docs.mql4.com/constants/uninit it contains the meaning of each uninit reason in my example 1 means that i manually removed it.

Hope this helps.

Hazem Lotfy.

 
Try this:
Create new Script, copy code from EA, then replace the code from Script with the code from EA. Add somewhere ( not in init ) loop (endless) and add the pause Sleep function like:
bool start=1; while(start) { /* do code from EA */ Sleep(seconds*1000); }
Test it. When you want to stop the EA program Script, change the timeframe/chart, or close the chart.
Note: If you change account (login to another one) the script will not stop, and will continue working on next login account. If you want to prevent that you have to add additional account checking.
 

"Could there be something in my code that is causing the problem? I'm sure I'm not the only person leaving an EA on continuously so if I have the problem and nobody else does I must be doing something wrong."

The majority of the EA's in the recent Contest ran for three months unattended, and did not fault like that.

Show some code, maybe there is something you can't see.