I now add some information about the status of the EA, and the parameters passed to the callbacks.
The call to OnDeinit passes an integer value called ‘reason’. I wrote a simple class with a static function which will translate the integer into a string.
struct UninitReason { static string ToString(int id) { switch (id) { case REASON_ACCOUNT: return "account was changed"; case REASON_CHARTCHANGE: return "symbol or timeframe was changed"; case REASON_CHARTCLOSE: return "chart was closed"; case REASON_PARAMETERS: return "input-parameter was changed"; case REASON_RECOMPILE: return "program was recompiled"; case REASON_REMOVE: return "program was removed from chart"; case REASON_TEMPLATE: return "new template was applied to chart"; } return "unknown " + IntegerToString(id); } };
I then called the static function ToString from my OnDeinit callback function:
void OnDeinit(const int reason) { Print(__FUNCTION__ + "; reason=" + UninitReason::ToString(reason)); }