1.5 KiB
1.5 KiB
OnDeinit
The OnDeinit() function is called during deinitialization and is the Deinit event handler. It must be declared as the void type and should have one parameter of the const int type, which contains the code of deinitialization reason. If a different type is declared, the compiler will generate a warning, but the function will not be called.
The Deinit event is generated for Expert Advisors and indicators in the following cases:
before reinitialization due to the change of a symbol or chart period, to which the mql4 program is attached; before reinitialization due to the change of input parameters; before unloading the mql4 program.
void OnDeinit(const int reason);
| Constant | Value | Description |
|---|---|---|
| REASON_PROGRAM | 0 | Expert Advisor terminated its operation by calling the ExpertRemove() function |
| REASON_REMOVE | 1 | Program has been deleted from the chart |
| REASON_RECOMPILE | 2 | Program has been recompiled |
| REASON_CHARTCHANGE | 3 | Symbol or chart period has been changed |
| REASON_CHARTCLOSE | 4 | Chart has been closed |
| REASON_PARAMETERS | 5 | Input parameters have been changed by a user |
| REASON_ACCOUNT | 6 | Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings |
| REASON_TEMPLATE | 7 | A new template has been applied |
| REASON_INITFAILED | 8 | This value means that OnInit() handler has returned a nonzero value |
| REASON_CLOSE | 9 | Terminal has been closed |