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

 

Alexey Volchanskiy

By the way, does MQL5 have a limit on the number of function parameters?

There seems to be 64 parameters per function.

 
Alexey Volchanskiy:

How do you optimise? It's not the first time I've asked this, and no one is saying anything.


That's the thing - you don't. It means that any custom window (DLL, GUI in MQL) will completely destroy the native optimization. In extreme cases, we have to add our own optimization inside the EA, which is another bicycle.

The ini file is the same. How it is convenient here is not clear at all. At least, I have not seen simple users who edit the ini file in order to change values of tuning parameters.

 
Alexey Volchanskiy:

I seem to have written clearly enough, but I'll repeat it with an example. There is an Expert Advisor, it has 100 input parameters, all of them should be passed 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.

So the problem is how to pass input variables to the algorithm class instance

Then you got it right.

// Begin: mqh-файл
class CLASS_EXPERT
{
public:  
  template <typename T>
  void Set( void );
};
// End: mqh-файл

input int inNum = 0;

struct INPUTS
{
  const int Num;
  
  INPUTS( void ) : Num(inNum)
  {
  }
};

CLASS_EXPERT Experts[10];

void OnInit()
{
  for (int i = ArraySize(Experts) - 1; i >= 0; i--)
    Experts[i].Set<INPUTS>();
}
 
Ihor Herasko:

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

ExpertLoader_Example.mq5 from here.

Ihor Herasko:

This is the point, it does not. It means any custom window (DLL, GUI in MQL) will completely destroy the standard optimization. In extreme cases, we have to add our own optimization inside the EA, which is another bicycle.

The ini file is the same. How it is convenient here is not clear at all. At least, I haven't seen any simple users who edit the ini file in order to change the values of tuning parameters.

https://www.mql5.com/ru/docs/optimization_frames/parametersetrange

Expert
Expert
  • votes: 16
  • 2017.08.28
  • fxsaber
  • www.mql5.com
Все остальные файлы на данной странице описания библиотеки являются ее примерами/сценариями применения и не нужны для работы самой библиотеки. Возможности Примеры К описанию прикреплены примеры/сценарии ее использования. ExpertsRemove.mq5 ExpertsReopen.mq5 ChartsClose.mq5 ExpertLoader_Example.mq5 ExpertsChange_Example.mq5 Это...
 

You can write the external variables in an mqh file and plug it in.

 

I must be behind the times or moving in the wrong direction,

I thought that the less input parameters an EA has, the better.

Ideally, in my opinion, an EA should have no input parameters(input variables).

Explain to me, what is the meaning of 100 parameters?

 
Sergey Chalyshev:

I must be behind the times or moving in the wrong direction,

I thought that the less input parameters an EA has, the better.

Ideally, in my opinion, an EA should have no input parameters(input variables).

Please tell me, what is the meaning of 100 parameters?


Just for experimentation.

 
Sergey Chalyshev:

I must be behind the times or moving in the wrong direction,

I thought that the less input parameters an EA has, the better.

Ideally, in my opinion, an EA should have no input parameters(input variables).

Please clarify the meaning of 100 parameters.


This question is not discussed here. We are discussing the technical aspects of parameter passing.

 
Dmitry Fedoseev:

You can write the external variables in an mqh file and plug it in.


I'm losing my mind, people are stubbornly ignoring me. You can also write them in .mqh, what difference does it makehow to pass them to the algorithm class?

 
Alexey Volchanskiy:

I'm losing my mind, I'm still not being heard. You can also use .mqh, what difference does it makehow to pass them to the algorithm class?


You don't need to pass them, global variables are available as is.