|
OnDeinit
The function is called in indicators and EAs when the Deinit event occurs. It is used to deinitialize a running MQL5 program.
void OnDeinit(
|
Parameters
reason
[in] Deinitialization reason code.
Return Value
No return value
Note
Deinit event is generated for EAs and indicators in the following cases:
The reason parameter may have the following values:
Constant |
Value |
Description |
---|---|---|
REASON_PROGRAM |
0 |
The EA has stopped working calling the ExpertRemove() function |
REASON_REMOVE |
1 |
Program removed from a chart |
REASON_RECOMPILE |
2 |
Program recompiled |
REASON_CHARTCHANGE |
3 |
A symbol or a chart period is changed |
REASON_CHARTCLOSE |
4 |
Chart closed |
REASON_PARAMETERS |
5 |
Inputs 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 |
Another chart template applied |
REASON_INITFAILED |
8 |
The OnInit() handler returned a non-zero value |
REASON_CLOSE |
9 |
Terminal closed |
EA deinitialization reason codes can be received by the UninitializeReason() function or from the predefined _UninitReason variable.
Sample OnInit() and OnDeinit() functions for the EA
input int fake_parameter=3; // useless parameter
|
See also
OnInit, Event handling functions, Program running, Client terminal events, Uninitialization reason codes, Visibility scope and lifetime of variables, Creating and deleting objects