When debugging, the debugger randomly stops with Uninit Reason 4 (Chart Closed)

 

As the title says, when debugging, the debugger randomly stops with uninit reason 4 ("Chart Closed" according to the Uninitialization Reason Codes).

‌It could be anywhere from 7-15 minutes.‌

I'm not closing the chart and there's no functions in the EA that would cause the chart to close or even messes with the chart (other than, perhaps, OnChartEvent). In fact, I just leave the EA running without me messing with it to be absolutely sure that it's doing this on its own.

‌I even set up breakpoints where the code of if statements would process if the conditions were met, just to see if something fishy is going on, and the breakpoints aren't triggered so I know the code is running smoothly (or at least I believe it is).

It's too much code to share in a forum post, so before I delve any deeper into this, I'm just wondering‌ if this is expected behavior. For example, maybe the debugger closes after a while if it doesn't receive any user input or something?

 
No it's not expected. Which build is it ?
 
Alain Verleyen:
No it's not expected. Which build is it ?

Build 1049.

‌Unfortunately, the markets are closed, but I just thought about debugging another EA to see if I experience the same issue.

 
I also reported this behaviour to the service desk. There is a newer build, but the problem is the same.
 
Doerk Hilger:
I also reported this behaviour to the service desk. There is a newer build, but the problem is the same.
Thanks for sharing. It sucks not knowing if you're experiencing an isolated issue or a known issue.
 
This happens occasionally to me too while I was debugging an indicator (mt4 b1031). I pressed Shift +F9 and debugging ended - a restart passed that code line.
 
I happened this problem this days.I could't resolve it.I had try my EA(Empty) on other PC but also .Hope the superman save me !
 

I've never found the debugger to be super stable.

When I use it I try to set breakpoints that exactly match my area of interest rather than long debug sessions that repeatedly stop inside loops

YMMV

 

I've also encountered this problem when debugging an indicator.  Even after I commented-out nearly 100% of the code, the debugger would randomly stop with "uninit reason 4".  I can tell you what solved the problem for me -- though I'm not sure this is a solution for others.

The same indicator that I was debugging was also attached to another chart.  When I closed all charts that had the same indicator attached, then the debugger no longer randomly stopped.  In hindsight this is probably correct behavior and not a bug -- though MT4 should probably alert you in some way that you are about to debug an indicator or EA that is already running.

 
sleytus:

I've also encountered this problem when debugging an indicator.  Even after I commented-out nearly 100% of the code, the debugger would randomly stop with "uninit reason 4".  I can tell you what solved the problem for me -- though I'm not sure this is a solution for others.

The same indicator that I was debugging was also attached to another chart.  When I closed all charts that had the same indicator attached, then the debugger no longer randomly stopped.  In hindsight this is probably correct behavior and not a bug -- though MT4 should probably alert you in some way that you are about to debug an indicator or EA that is already running.

Thank you for the response, all help is appreciated. I can't recall which EA it was, but I am working on another EA that suffers from the same problem. However, the EA isn't running on any other chart than the Debugger. With that said, I'll try creating a new profile and closing all other charts and then try again. If I had to guess, I think it has something to do with checking for open and pending orders. That's the only similarities between the two EAs that I can think of.

Thank you, once again, sleytus.

 

Problem seems to exist still?!

My EA which creates indicators with indicatorCreate also stops in debugger right after a position is opened. (Version 5 Build 2715 )

However when I test the EA via terminal "Start test" then it does not stop, so it must be an issue with the debugger.

Reason: