deadlock in start() during deinit(), mt4 freezing, kill it and lose any changes to chart objects

 

for the second time in a week I have managed to crash (freeze and kill) MT4 and when this happens I lose all objects that were drawn into a chart since it was started.


The freeze happens during timeframe switching, something I do in start() seems to run into a deadlock, most often MT4 will timeout the EA after 2 seconds but once in a while it fill freeze forever. Then I have to kill the MT4 process. I have not been able to debug this yet, I have no idea what it could be, I have almost given up, so I am searching for a workaround:


Is there any other way than exiting MT4 normally and restarting it to save the Objects that were drawn into a chart?

 

Hi 7bit, 

You may have already consider this. But here's a suggestion FWIW :

Assuming you draw the Objects through the EA : Put all parameter values to GlobalVariables first & make sure it draw objects solely using that GV values. When the EA is restarted Objects will automatically fetch & re-drawn using the saved GV values. Hope this helps. 

cameo 

 

Found at least the reason for the deadlocks and a way to avoid them: It was the WindowHandle() function that would block and never return during a shutdown.


The question about the chart objects is still unsolved. I don't want to pollute the global variables with this, there are thousands of little arrows plotted during EA execution, they are not so important that they must be persisted at all costs but it would be nice if I could just save the current state of the chart from time to time. I did not find a menu item for this but I was hoping there would be some other operation that I could trigger and that would have the side effect of saving the charts.

 
7bit:

Found at least the reason for the deadlocks and a way to avoid them: It was the WindowHandle() function that would block and never return during a shutdown.

The question about the chart objects is still unsolved. I don't want to pollute the global variables with this, there are thousands of little arrows plotted during EA execution, they are not so important that they must be persisted at all costs but it would be nice if I could just save the current state of the chart from time to time. I did not find a menu item for this but I was hoping there would be some other operation that I could trigger and that would have the side effect of saving the charts.

Yes, I would suspect that you have other things in mind, given your skills. 

Yet I have another idea you would potentially dismiss....:). Template files if opened contains chart commands, state of objects & indicators drawn. Maybe you can mess around with that. 

 
7bit:

they are not so important that they must be persisted at all costs but it would be nice if I could just save the current state of the chart from time to time


7bit do you have any issue with your hst files not being updated? IIRC the hst files are only updated with the candle data stored in memory if the terminal closes "gracefully". There is no intermediate updating of the hast file. If your terminal is open for 2 wks then you have 2wks worth of hst data stored in ram but not on your hdrive...have a terminal crash at that point and the data are gone save for what can be re-refreshed from the broker once you restart the terminal. (which in the case of M1 data may not be all that much, a day or two)
 
1005phillip:

7bit do you have any issue with your hst files not being updated? IIRC the hst files are only updated with the candle data stored in memory if the terminal closes "gracefully". There is no intermediate updating of the hast file. If your terminal is open for 2 wks then you have 2wks worth of hst data stored in ram but not on your hdrive...have a terminal crash at that point and the data are gone save for what can be re-refreshed from the broker once you restart the terminal. (which in the case of M1 data may not be all that much, a day or two)

the .hst files not updating is a similar effect but currently I have no need to access them. It would have been nice if could just have a separate application access "reatime"quotes through the .hst files but I can live without it.


The only thing that really annoys me is that I lose the arrows plotted into the chart.

 

deadlock in start() during deinit()

Why are you calling start() during deinit()? Save what you need and exit.
 
WHRoeder:

deadlock in start() during deinit()

Why are you calling start() during deinit()? Save what you need and exit.

where did I write that i call start in deinit? And also I wrote that it is solved already (scroll up and read). It was caused by a bug in MT4, the WindowHandle() function will block and never return during timeframe switching and sometimes even freeze MT4 completely.


This thread is mainly about saving the chart without exiting MT4.

 

7bit it is a literal interpretation of your own thread's title...deadlock in start() during deinit()...which implies that during deinit() you are calling start() and while doing so you are experiencing deadlock situations.

 
i admit the title might be misleading. what I meant (and later explained in the text) was a deadlock inside start() during the deinitialization process or more precisely after the very moment mt4 has decided it will now (soon) deinitialize the ea while the latest start() call is still running. WindowHandle() which I called somewhere inside start() would block and completely freeze MT4 in such a (rare) event.
Reason: