Forcing an EA to exit

 

Is there a way to exit out of an EA from withing the EA itself?

I'm not talking about exiting the current iteration of the start() function, but forcing the EA to remove itself from the chart..thus forcing the deinit() function to run?

 

Functions of start(), init(), and deinit() can be called from any point of the module according to the common rules, equally to other functions.

I don't think calling deinit will help you.


// Expert Advisor Test
int init()
 {
   Comment("\nINIT function runs...");
   return(0);
 }
int deinit()
 {
   Comment("\nDE-INIT Function runs... Now WAITING FOR TICK");
   return(0);
 }
int start()
 {
   Comment("\nSTART function runs ", GetTickCount()); 
   Sleep(1000);
   init();
   Sleep(1000);
   deinit();
   Sleep(1000);
   return(0);
}
 
If it is a one-time job you could use a script instead of an EA. It is automatically disabled when its job is done.
Reason: