Bug in reason codes for OnDeinit() function

 

Can anyone explain why the unin reason code is '1' when the external input paramaters are changed in an MQL5 indicator.

 

The mql5 reference says when a user changes an external input the system should return '5' as the reason code. Whenever I change my external input parms I get a '1' for the reason code.

 

I have simply put a 'Print ("Reason code=",reason) in the first line of the OnDeinit() function. 

 

Bug..??  

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Running MQL5 Program Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Running MQL5 Program Properties - Documentation on MQL5
 

This behaviour is not bug, because changing of external parameter of indicator leads to create an instance of new one and kills current indicator. See also Program Running:

Loading and Unloading of Indicators

Indicators are loaded in the following cases:

  • an indicator is attached to a chart;
  • terminal start (if the indicator was attached to the chart prior to the shutdown of the terminal);
  • loading of a template (if the indicator attached to a chart is specified in the template);
  • change of a profile (if the indicator is attached to one of the profile charts);
  • change of a symbol and/or timeframe of a chart, to which the indicator is attached;
  • after the successful recompilation of an indicator, if the indicator was attached to a chart;
  • change of input parameters of the indicator.

 

Indicators are unloaded in the following cases:

  • when detaching an indicator from a chart;
  • terminal shutdown (if the indicator was attached to a chart);
  • loading of a template, if an indicator is attached to a chart;
  • closing of a chart, to which the indicator was attached;
  • change of a profile, if the indicator is attached to one of charts of the changed profile;
  • change of a symbol and/or timeframe of a chart, to which the indicator is attached;

 
Rosh:

This behaviour is not bug, because changing of external parameter of indicator leads to create an instance of new one and kills current indicator. See also Program Running:


Rosh, 

Thanks for your reply.

Based on the Program Running design you guys have used it doesn't seem possible for the system to differentiate between an change in external inputs and the removal of an indicator from the chart.

Essentially both operations return unin reason code 1.

I can successfully retrieve reason codes:

3 (chart change),  4 (removal of chart), 7 (template load),

But modifying input parameters declared using 'input color Text_Col=White' always returns unin reason code 1 even though the documentation seems to support reason code 5 for external input parm changes. 

Pretty foxed on this one as I need to be able to pick out the reason codes pretty accurately for what I'm doing.  

Cheers

FX AlgoTrader