Removing a EA when the program has an error

 

is there a code that would allow me to remove the program or deinit the program if there is an error?

 example:

if(GetLastError() != 0)

{  

Alert("error"); 

exit EA, de initialize

 

Also, the error would come from the program trying to put a buystop/sellstop at a point that isnt allowed to put an order. So it could also be if the order fails.  

If there is no other way, is there a way to run the EA with minimal CPU? So that it would not lag the other EA that are running in other symbols

Thanks 

 
Look up ExpertRemove in the documentation
 
GumRai:
Look up ExpertRemove in the documentation
Thanks again !!
Reason: