Documentation
MQL5 ReferenceMQL5 programsRuntime Errors 

Runtime Errors

The executing subsystem of the client terminal has an opportunity to save the error code in case any occurs during a mql5-program run. There is a a predefined variable _LastError for each executable mql5 program.

Before starting the OnInit function, the _LastError variable is reset. In case an erroneous situations occurs during calculations or in the process of internal function calls, the _LastError variable accepts a corresponding error code. The value stored in this variable can be obtained by using the GetLastError() function.

There are several critical errors, appearing which a program is terminated immediately :

  • division by zero;
  • going beyond array ranges;
  • using an incorrect object pointer;