How to force the termination of the program? Something like "exit (-1)" please?

 

I am looking for something that allows me to kill the thread of the program when an error occurs.

Something like "exit(-1)" in C and C ++.

Can you please tell me if there is something similar in MQL5?

I want to do something like what you can see in the following code:

         handler = iMA(pSymbol,pTimeFrame,pPeriod,0,pMaMethod,pAppliedPrice);         
         
         if(handler == INVALID_HANDLE)      
         {
            Print(__FUNCTION__, " Error MA: INVALID_HANDLE!! Code = ", GetLastError() );
            exit(-1);//kill the progam
         }
 
karp wak:

I am looking for something that allows me to kill the thread of the program when an error occurs.

Something like "exit(-1)" in C and C ++.

Can you please tell me if there is something similar in MQL5?

I want to do something like what you can see in the following code:

ExpertRemove().
 
karp wak: I am looking for something that allows me to kill the thread of the program when an error occurs. Something like "exit(-1)" in C and C ++. Can you please tell me if there is something similar in MQL5? I want to do something like what you can see in the following code:
Besides the answer from Alain about using ExpertRemove(), If you are doing that in the OnInit() handler, then exit properly with a return and a INIT_FAILED exit code, instead.
 
Alain Verleyen:
ExpertRemove().

Thank you very much Alan !!

 
Fernando Carreiro:
Besides the answer from Alain about using ExpertRemove(), If you are doing that in the OnInit() handler, then exit properly with a return and a INIT_FAILED exit code, instead.

Thank you very much Fernando !!