//+------------------------------------------------------------------+ //| UnInit_Codes.mq4 | //| | //| | //+------------------------------------------------------------------+ #property copyright "" #property link "" #property version "1.00" #property strict #property indicator_chart_window //for checking uninit code after parameter change input bool parameter1 = false; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| get text description | //+------------------------------------------------------------------+ string getUninitReasonText(int reasonCode) { string text=""; //--- switch(reasonCode) { case REASON_ACCOUNT: text="Account was changed";break; case REASON_CHARTCHANGE: text="Symbol or timeframe was changed";break; case REASON_CHARTCLOSE: text="Chart was closed";break; case REASON_PARAMETERS: text="Input-parameter was changed";break; case REASON_RECOMPILE: text="Program "+__FILE__+" was recompiled";break; case REASON_REMOVE: text="Program "+__FILE__+" was removed from chart";break; case REASON_TEMPLATE: text="New template was applied to chart";break; default:text="Another reason"; } //--- return text; } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- The first way to get the uninitialization reason code Print(__FUNCTION__,"_Uninitalization reason code = ",reason); //--- The second way to get the uninitialization reason code Print(__FUNCTION__,"_UninitReason = ",getUninitReasonText(_UninitReason)); }