Download MetaTrader 5

How to know if an indicator is first run

To add comments, please log in or register
Wang Qi
Wang Qi  

Hi all,

Before all, let me define "first run". From MQL documentation,

Loading and Unloading of Indicators

Indicators are loaded in the following cases:

  • an indicator is attached to a chart; (This is first run)
  • terminal start (if the indicator was attached to the chart prior to the shutdown of the terminal); (This is first run)
  • 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.

I add "(This is first run)" in the list, so only the first two cases are first run.

How to detect if an indicator is first run?

What I want to do is, when an indicator is first run, pop up a dialog to ask to input license code. If the dialog is pop up on every parameter change, it will be too annoying.

Or an alternative question, how to let the user input the license code? Maybe an alternative method is to put a button on the chart?

Thanks for your any advice.

Ex Ovo Omnia
Ex Ovo Omnia  
  1. OnTick(){
       static bool isFirstRun = true;
       if(isFirstRun){ isFirstRun = false; ...
  2. Use a input string and verify in OnInit.
To add comments, please log in or register