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

 

So you still need real input variables!

Parameters

name

[in] The identifier ofinput or sinput variable. These variables are external parameters to the program whose values can be set at startup.

 
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?


Here's an example.

Files:
test.zip  8 kb
 
Alexey Volchanskiy:

So you need real input variables anyway!

No one is stopping you from writing them in the source.

 
fxsaber:

No one is stopping them from prescribing them in the source.


A white bull's tale )) How to pass them to the algorithm class in normal trade?

 
Alexey Volchanskiy:

A white bull's tale )) How to pass them to an algorithm class in regular trading?

Forum on trading, automated trading systems and strategy testing

And why not put the input parameters in the structure?

fxsaber, 2017.10.02 20:15

// 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>();
}
 
fxsaber:

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


Here's an example, from the front page.

struct VolumeParams                              
{
    double lot;         //Лоты
    double LotRatio;    //Множитель
    int tp;             //ТП
    int sl;             //СЛ
    int orders;         //Количество ордеров
};
VolumeParams ParamBuf[5];

input ParamBuf[0];         // Шаг 1
input ParamBuf[1];         // Шаг 2
input ParamBuf[2];         // Шаг 3
input ParamBuf[3];         // Шаг 4
input ParamBuf[4];         // Шаг 5

plus my quote.

...here's the customer wants 10 inputs, and each step has its own tp/sl/lot/trall/signal to input

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

With this design, it's easy for the programmer to initialize an array of input parameter structures and then work with it.

Expand all these parameters into separate variables and try to work with them.

 
Taras Slobodyanik:

here is an example, from the first page

When launching a TS, it often happens that you don't know which input parameters are better to choose. So you run an Expert Advisor that has, for example, a dozen sets of different input parameters. And each set for each copy of the TS. Many people have been doing this a long time ago, when MQL4 was still very far from MQL5.

And they did it through extern string - now it's called an input string.

input string Parameters = "1, 2, 3.5, 8, 9l";

They parsed the input strings, checked how many input lines there were and used this number to create the same number of trade logic with appropriate input parameters (using ArrayResize). And all this on the ancient MQL4! And there, the MM was distributed for each TS according to the number of TCs and other nuances. Somewhere in the ancient codebases there should be examples.

 

yes, but it's not possible to optimise in this way

1

 
Taras Slobodyanik:
yes, but this is not how optimisation is possible

You are making up hypothetical problems that have nothing to do with reality. If Optimisation is needed, it is done in elementary fashion. Note the highlighted word. There is no technical hurdle. If you can't organise Optimisation in this case, then you need it so much.

There are a lot of practical techniques to solve this or that need. But they are far from hypothetical problems.

 
fxsaber:

You are making up hypothetical problems that have nothing to do with reality. If Optimisation is needed, it is done in elementary fashion. Note the highlighted word. There is no technical hurdle. If you can't organise Optimisation in this case, then you need it so much.

There are a lot of practical techniques to solve this or that need. But they are far from hypothetical problems.

the topic is not about optimisation)
Why not put the input parameters in the structure?
Reason: