Why not put the input parameters in the structure? - page 3

 
Комбинатор:
Then set parameters with a file.

By the way, yes.

If there are a lot of parameters, in my opinion, an INI file is "just what the doc ordered".

You can use directly ready-to-use Windows functions to work with INI-files. Although, I have my own, self-written.

 
Taras Slobodyanik:

So it applies, to write all that pile of parameters, it would be enough to define the structure and put it in the input parameters.


Yes, that's right.

 
Alexey Volchanskiy:

Yes, that's right.

Can you show me an example of convenience? I can't figure out what you're talking about.

 
Ihor Herasko:

So it's not surprising to see two windows for the settings: a standard window and a new one?

Run the EA without the standard window.

 
fxsaber:

That's not what this thread is about, as it mentions an mqh-file. And defining the structure is the same as writing all the fields. In other words, it's the same thing.


I think I've written quite clearly but I'll repeat it using an example. We have an Expert Advisor, it has 100 input parameters, and we have to pass them all to an instance of the class of the algorithm where all the work takes place. There are two ways:

  1. Make the parameter setting function(s) in the class. Now imagine a function with 100 parameters. By the way, is there a limit on the number of function parameters in MQL5?
  2. The class is defined after the input variables, i.e. they are visible from the EA. The disadvantage - less flexibility in case of multiple instances of the class. The plus is the minimum amount of writing.

    input double LotSize = 0.1;
    // другие 100 input переменных...
    
    #include <MyLib\MyClassEA.mqh>
    CMyClassEA MyEA;
So the problem is how to pass input variables to an instance of the algorithm class
 
fxsaber:

Can you show me an example of convenience? I can't understand what we're talking about.


What is easier, to pass 100 parameters to the initialization function or a reference to one structure with input parameters?

 
George Merts:

By the way, yes.

If there are a lot of parameters, I think an INI file is just "what the doc ordered".

You can use directly ready-to-use Windows functions to work with INI-files. Although, I have my own, self-written ones.


The point is to leave the possibility of standard optimization. Is it really possible to do so with ini?

 
Ihor Herasko:

This is the way it is done now. At the same time, the Expert Advisor comes with an "Editor" of such a file in the form of a DLL, which displays a window with tabbed parameters.

That is, everything is possible. No one argues with that. Another thing is that if it was in the form of ready-made functionality in the terminal, it would be cool.


And how do you optimize it? It's not the first time I've asked this question and nobody is saying a word.

 
Alexey Volchanskiy:

The point is to leave the possibility of standard optimisation. Is it possible with ini?

It is possible. But I don't understand why ini.

 
fxsaber:

Run the EA without the standard window.


How is that possible? I really don't understand how this is possible. I know this trick for scripts, but not for EAs and indicators.

Reason: