Quitting an EA safely

 

I noticed that in some cases when an EA quits, it will remove your EA and consequently all settings associated with the EA are gone (because the EA is gone)... this is very undesirable behaviour for me.

I think I noticed this when returning a failure code from OnInit()

I want to write some assert function ... (or does anyone know some good assert libraries for MQL4&5 - work with both I mean) ?

I want to quit the EA if the assertion fails but I don't want to lose my EA on the chart.

What command should I use in MQL to do this?

 
ycomp:I noticed that in some cases when an EA quits, it will remove your EA and consequently all settings associated with the EA are gone (because the EA is gone)... this is very undesirable behaviour for me. I think I noticed this when returning a failure code from OnInit(). I want to write some assert function ... (or does anyone know some good assert libraries for MQL4&5 - work with both I mean) ? I want to quit the EA if the assertion fails but I don't want to lose my EA on the chart.What command should I use in MQL to do this?

Your query does not make sense. If you don't want to loose your EA properties, then save them as a .set file and load them them when you place the EA on the chart.

Also, if you don't want the OnInit() function to "fail", then don't return the value INIT_FAILED. Instead return the value INIT_SUCCEEDED and handle the situation within the EA functionality, by warning the user via an Alert() or printing it to the log file or some other method. Personally I don't think that is a good practice, but that is up to you.

 
Fernando Carreiro #:

Your query does not make sense. If you don't want to loose your EA properties, then save them as a .set file and load them them when you place the EA on the chart.

Also, if you don't want the OnInit() function to "fail", then don't return the value INIT_FAILED. Instead return the value INIT_SUCCEEDED and handle the situation within the EA functionality, by warning the user via an Alert() or printing it to the log file or some other method. Personally I don't think that is a good practice, but that is up to you.

yes I used this workaround already about INIT_SUCCEEDED on fail.

my question is if the other ways to terminate an EA (I forget the exact function names), will also cause the EA to get removed from the chart - or if it will just stop operation of the EA but keep the settings on the chart intact.

 
ycomp #: my question is if the other ways to terminate an EA (I forget the exact function names), will also cause the EA to get removed from the chart - or if it will just stop operation of the EA but keep the settings on the chart intact.

If you are referring to the ExpertRemove() function, then obviously the "expert" will get "removed" from the chart, just as the name of the function states.

Again, I will repeat, that you can save the EA's "inputs" to a set file so they can be loaded again and reused.


 
Fernando Carreiro #:

If you are referring to the ExpertRemove() function, then obviously the "expert" will get "removed" from the chart, just as the name of the function states.

Again, I will repeat, that you can save the EA's "inputs" to a set file so they can be loaded again and reused.


A modern software could allow to do that automatically. A human can forgot to do it.
 
ycomp #:

yes I used this workaround already about INIT_SUCCEEDED on fail.

my question is if the other ways to terminate an EA (I forget the exact function names), will also cause the EA to get removed from the chart - or if it will just stop operation of the EA but keep the settings on the chart intact.

Just add code in your EA to save the settings.
 
Alain Verleyen #:
A modern software could allow to do that automatically. A human can forgot to do it.

yes, especially when there is more than one EA running on more than one terminal