Errors, bugs, questions - page 1492

 
Maxim Khrolenko:
And global (not external) is not, and that's not good.

Why is it not good? It is explicitly said that global variables are initialised once at program startup.

You want different behavior, initialize as you want in OnInit

 
Yuri Evseenkov:
It would be good to reflect this in the documentation.
Yes. We will.
 
zaskok3:
In MQL4++ I can't do without extern when I need to change input parameters programmatically. For example, when converting a standard indicator into an interactive one I have to replace input with extern. The compiler treats input variables as const and complains at attempt to change them. With extern there will be no such problems.

Use "doublers" of input parameters

We have an example in MQL5\Indicators\Examples\ADX.mq5.

//--- input parameters
input int InpPeriodADX=14; // Period
//---- buffers
double    ExtADXBuffer[];
double    ExtPDIBuffer[];
double    ExtNDIBuffer[];
double    ExtPDBuffer[];
double    ExtNDBuffer[];
double    ExtTmpBuffer[];
//--- global variables
int       ExtADXPeriod;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//--- check for input parameters
   if(InpPeriodADX>=100 || InpPeriodADX<=0)
     {
      ExtADXPeriod=14;
      printf("Incorrect value for input variable Period_ADX=%d. Indicator will use value=%d for calculations.",InpPeriodADX,ExtADXPeriod);
     }
   else ExtADXPeriod=InpPeriodADX;
 
Comrades, does anyone regularly get "Internal compiler error" when compiling? No apparent reason, in the case of recompilation - hangs, in the case of closing the editor, reopen (with the same tabs, with the same code) - compilation is usually normal. Nothing changes in the code! But sometimes this error occurs several times in a row and the first restart of the editor does not help. So far, as a result of reloading everything managed to compile. But I'm afraid that sooner or later it will stop working. I'd like to find someone else who encountered similar bugs, so that together we could provide servicedesk with data about the conditions of their occurrence.
 
Slawa:

Use "doublers" for input parameters

We have an example in MQL5\Indicators\Examples\ADX.mq5

Now, to convert an indicator to the interactive version, you need to add only one line to the source code. If you make the doublers, in addition to the additional string for creation of the doubler, you must make replacement of the entire text. Why this hassle when you can simply change one line.

What prevents you from removing const-awareness of input variables at compile time?

 
zaskok3:

To convert the indicator into an interactive variant you only need to add one line to the source. If you make a double, then in addition to the extra line to create a double, you will need to replace the entire text. Why this hassle when you can easily change one line.

What prevents you from removing const-awareness of input variables at compile time?

Text editing. "Ctrl" + "H" - search and replace. Nothing complicated. Just don't be lazy.
 
zaskok3:

What prevents you from removing const-awareness of input variables at compile time?

Global storage of indicators in the MT5 history base. For them the input parameters are key. When you change the input parameters, the indicator with the old parameters is destroyed and the same indicator with modified parameters is created again.

That is, the restriction is purely architectural

In the fourth version we could remove the constancy from the instances, but then there is an incompatibility of the new MQL4 and MQL5. Therefore, we will not do it. Please continue using extern

 

Slawa:

That is, the limitation is purely architectural.

It's a pity that the architecture is so rigid that there is no possibility of even simple flexibility. It turns out that interactivity in MQL5 will require a crutch. The question is, where is the advantage then, if the language limits the possibilities...
 
pako:
Window to detach from the terminal
how?
 
Joo Zepper:
how?
It was on a forum somewhere, a DLL
Reason: