UninitializeReason(): What is different REASON_CLOSE vs. REASON_CHARTCLOSE?

 

Hi guys,

The function UninitializeReason() the same value (REASON_CHARTCLOSE) for

a) close chart

Close chart

b) close mt4 terminal

Close mt4 terminal

from log file:

17:44:49 Expert aaa EURUSD..,M30: loaded successfully

17:44:57 aaa EURUSD..,M30: initialized

17:45:07 Expert aaa USDCHF..,M1: loaded successfully

17:45:08 aaa USDCHF..,M1: initialized


17:45:16 aaa USDCHF..,M1: uninit reason 4

17:45:16 aaa USDCHF..,M1: aaa: Chart was closed

17:45:19 Expert aaa USDCHF..,M1: removed


17:45:28 aaa EURUSD..,M30: uninit reason 4

17:45:28 aaa EURUSD..,M30: aaa: Chart was closed

17:45:30 Expert aaa EURUSD..,M30: removed

??? How get event close MT4 terminal? Why mql no return ad b) REASON_CLOSE code?

Thank you.

 

Hmm...

I find way how catch event close MT4. I thought that code

REASON_CLOSE

9

Terminal has been closed

will be solution for my case, but it isn´t! :-( For close MT4 return code 4: REASON_CHARTCLOSE

 
check what happens if you terminate Meta Trader using CTRL + ALT + DEL ---> Processes ---> highlight terminal.exe ---> end process
 

Hi gjol,

I do it, but nothing new rows in log file, I done five test. Always nothing new rows.

my test code:

string INIT_STR_TEST="INIT";
string text="";
int OnInit()
{
  Print("INIT_TEST=",INIT_STR_TEST);
  return(INIT_SUCCEEDED);
}

// MT4 function called during deinitialization of the module
//+-------------------------------------------------------------------------------------------+
void OnDeinit()
{
   string text="";
   switch(_UninitReason)
     {
      case REASON_ACCOUNT:
         text="Account was changed"; INIT_STR_TEST="REASON_ACCOUNT"; break;
      case REASON_CHARTCHANGE:
         text="Symbol or timeframe was changed"; INIT_STR_TEST="REASON_CHARTCHANGE";break;
      case REASON_CHARTCLOSE:
         text="Chart was closed"; INIT_STR_TEST="REASON_CHARTCLOSE"; break;
      case REASON_PARAMETERS:
         text="Input-parameter was changed"; INIT_STR_TEST="REASON_REASON_PARAMETERS"; break;
      case REASON_RECOMPILE:
         text="Program "+__FILE__+" was recompiled"; INIT_STR_TEST="REASON_REASON_RECOMPILE"; break;
      case REASON_REMOVE:
         text="Program "+__FILE__+" was removed from chart"; INIT_STR_TEST="REASON_REMOVE"; break;
      case REASON_TEMPLATE:
         text="New template was applied to chart"; INIT_STR_TEST="REASON_TEMPLATE";break;
      case REASON_CLOSE:
         text="Terminal has been closed"; INIT_STR_TEST="REASON_CLOSE";break;
 
      default:text="Another reason"; INIT_STR_TEST="Another reason"; break;
    }
    Print("aaa: ", text);
/*  
  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
*/ 
   //return(0);
}
 
Hmm, nothing yet...???