I suggest that in this branch we discuss the possibility of automatic code generation based on a template and its automatic compilation at the request of the expert Advisor.

For example, I will tell you about my task:

1. there Are files with data, the data are variables of different types with an assigned value

2. you need to read the data and make it an array of data or enum or something else, so that one line from the file corresponds to one set of variables. This is tedious to do for each file.

3. taking into account the data from the file, generate a code counter that can iterate through all combinations of sets of variables.

4. Save the result to a file to connect to the expert Advisor/other code

Here, in General, the task is theoretically not difficult, except that it is necessary to somehow automate the process of creating a template. Is it even possible to do this using MQL?

And you need all this to speed up the optimization process, if there are a lot of variables and they belong to groups (for example, independent filters).

## -aleks-

How can you take one of the two if they have different functions and logic???

## denkir

You need to compare the distributions of the effective indicator from each of the filters. If they are different, it means, firstly, that the filters work differently, and secondly, you can take the one with the best indicators.

## -aleks-

You understand correctly, so I do-I cross all the options in search of the greatest efficiency – efficiency is a reduction in loss to a greater extent than revenue, while the resulting profit increase should not occur much slower than the revenue decreases, the fact and improvement of other relative indicators are important. By setting such conditions, we understand that if the filter in a single person does not meet these criteria, then when it is combined with other filters, the result will not be much better, and if we select options that meet these criteria, then we can expect that the result will not become much worse, but it can become better.

And what do you propose to do in the beginning – so tell us, maybe something brilliant.

## denkir

I agree here only with one thing: here the filter is the predictor, at best. At worst, a dummy.

Let’s go with my example, where there are 3 filters, and then I think badly, I’m afraid to get confused…

Let Ri be the i-th predictor.

If there are 3 filters then we have:

1) 3 first-level predictors: R1, R2, R3;

2) 2 second-level predictors: R1*R2 (effect of cohabitation of predictors R1 and R2), R1*R3, R2*R3;

3) 1 third-level predictor: R1*R2*R3 (effect of cohabitation of predictors R1,R2 and R3).

In total, we have 6 predictors (although of different levels, it is important to clarify)!

As far as I understand, you are now looking for optimal values for R1, R2 and R3 separately, getting private predictor results. Then you cross them in an attempt to find the optimal values of the entire group based on partial predictor results.

The question is, is this the right thing to do? And if not, what should be done in the beginning? :-))

## -aleks-

From Your answers, it is obvious to me that I was not able to explain the essence of the problem.

Let’s say we have 10 filters (filter-let there be an external indicator with a bunch of settings and a logic switch), each such filter has at least 5 variables, optimizing everything at once is the height of idiocy and irrationalism. Therefore, it is assumed to optimize each such filter separately, collect the selected options according to different criteria and thus represent a set of filter variables as a single variable. When data is collected for 10 filters, you will need to optimize between sets of parameters, not each parameter. And what would it be to automate this business and need an automatic code generator, well, or another alternative solution that does not take much time to create sets of variables and include all combinations in a common counter or just design in separate variables – one for each filter, this is if you need genetics.

This method works, I use it, it is effective, but I have to do everything with my hands, which is tiring, so I’m looking for an opportunity to speed up the process.

## denkir

IMHO, a template, and even with some automatic compilation, is not needed. Although here you can have a good time 🙂

You can write sample results to a bunch of*. set files. This is for example…

As far as I understand, then, based on Your task, the MQL program should read data from the file and form a*. set file, where a range of possible values will be specified for each optimized parameter. And then feed this file for subsequent optimization, a kind of fine-tuning.

If you open a set file with Notepad, it will list the parameters for which ranges can be set.

For example, I have such a parameter in the EA code as InpTakeProfit (take profit in points)

In the set file, the parameter looks like this:

`InpTakeProfit=300||100||50||500||Y`

That is, when optimizing, it will be used (at the end is Y, otherwise N). Start value is 100, step = 50, Final value = 500.

## -aleks-

Dennis Kirichenko:Well, all this can be done in frame mode. There are several articles on the topic, the last one too: VISUALIZATION of OPTIMIZATION RESULTS BY the SELECTED CRITERION

How is visualization related to collecting data for subsequent optimization?

## denkir

Well, all this can be done in frame mode. There are several articles on the topic, the last one too: VISUALIZATION of OPTIMIZATION RESULTS BY the SELECTED CRITERION

## -aleks-

Yes, I wrote in that thread about my idea, but I realized that either it is not clear or not interesting, so I decided to try to implement it here, if possible.

However, it is not particularly related to the launch of the second terminal, the idea serves as an alternative to blind genetic optimization, i.e. we conduct pre-training, and there is at least a direct search, even genetics. The point is to exclude obviously bad results, leaving potentially interesting sets of variables for each group of optimized parameters.

## denkir

The idea is not new. Discussed in the thread about articles. There, if I’m not mistaken, Roche wrote about a possible article that would describe how to run the Tester of another terminal from the Tester of one terminal.

I looked at the list of topics. In the Table first goes:

Optimization managementGraphical interface for launching the second terminal . MQL5