User Tools

Site Tools


trading:optimization

Optimization

It is discussed how to use and read the optimization results calculated by MetaTrader.

How to use the eaOPT

The eaOPT is an expert advisor that helps in recording the performance of each set of parameters of any expert advisor throughout the year.

Create the optimization report

As soon as eaOPT is launched it shows all the directories in the MetaTrader /Files folder (see figure 1).

Tip: it's a good idea to organize the folders by year and, for each year, by expert advisor. It's also advisable to keep the same input setting every new year so that comparisons can be made.

Figure 1: Navigation through the directories in eaOPT. The caption of the window keeps track of the current directory. Use the .. to go back to the parent directory.

As an optimization method, only the “slow” one (see figure 2) will be used so that every time it is executed all combinations will be evaluated.

Figure 2: The “slow” method of optimization in the Strategy Tester.

Every year, for each month, the optimization has to be run from January 1st up to MM.01, where MM is the current month (see figure 3). The input values must be kept always the same.

Figure 3: Example of optimization from January to December in the Strategy Tester.

The optimization reports have to be exported as an XML file and saved in the right folder (see figure 4).

At this point, the procedure to extract the data varies depending on if the relative CSV file already exists:

  • no CSV file: select the reports, in chronological order;
  • otherwise: first, select the CSV file, and then the new report.

Finally, press the “Extract” button.

Figure 4: List of the optimization reports for the specific expert advisor. The XML files are the reports created by MetaTrader while the CSV file is created by eaOPT. To undo a selected file, select it again.

To view only the CSV file, once it is selected, press the “Extract” button.

In the CSV file, the performance of each set of parameters is saved as comma-separated values of result and profit, since the beginning of the time span selected for the optimization:
[set][result_1,profit_1][…][result_n,profit_n]

Then, eaOPT rewrites these data in terms of monthly and average percentages:
[set][avg_percent][percent_1][…][percent_n]

Where:
[set]: combination of parameters tested;
[result_n]: balance at the end of the n-th month calculated from 01.01;
[profit_n]: net profit at the end of the n-th month calculated from 01.01;
[percent_n]: percentage monthly profit ([result_n] - [result_n-1]) / [result_n-1] * 100;

Figure 5: Percentage monthly profit for each set of parameters.

The expert advisor eaOPT allows to save in the CSV file the input settings used for the optimizations. Regarding the data, it's possible to highlight a particular combination of parameters or sort in ascending order each column, just by clicking on it.

Read the optimization report

The “Average” column shows the monthly average profit, in percentage, based on the first MM months specified in the above spinbox.

Figure 6: Calculation example of the monthly average profit as like the monthly profit, using the reports made by eaOPT.

Every new MM month will be chosen that combination of parameters whose monthly average profit was the maximum in the previous MM - 1 months (see table 1).

Table 1: Parameters choice and relative monthly profit, based on the example of figure 6.
month MM
(begin of MM)
parameters
(based on max average MM-1)
profit [%]
(at end of MM)
balance [€]
(at end of MM)
profit [€]
(at end of MM)
1 n.a. 250
2 4,100 13.06 282.65 32.65
3 4,150 16.44 329.12 46.47
4 4,150 -13.22 285.61 -43.51
5 5,400 -11.46 252.88 -32.73
6 6,1000 20.93 305.80 52.93
7 6,1000 38.15 422.47 116.66
8 6,1000 71.76 725.63 303.16
9 6,1000 10.23 799.87 74.23
10 6,1000 4.34 834.58 34.71
11 6,1000 -43.06 475.21 -359.37
12 5,1000 44.08 688.48 213.27

Info: this process of selection of the optimum set of parameters, in general, produces less profit than simply choosing a combination of parameters for the whole year because the former is supposed to close all open positions at the end of each month.

trading/optimization.txt · Last modified: 2023/09/04 22:55 by tormec