Strategy Tester -> Optimization Report not sorted ** Solved

 

Hi,

My EA auto-optimize its parameters (or try to ! ) by opening a new Terminal in optimization mode using optimise.ini like this one :

//Optimise strategy tester -----------------------------------
ExpertsEnable=false
TestExpert=1 Maturine 2009 09 21 K
TestExpertParameters=AUDUSD_4.set
TestSymbol=AUDUSD
TestPeriod=5
TestModel=0
TestRecalculate=false
TestOptimization=true
TestDateEnable=true
TestFromDate=2010.01.03
TestToDate=2010.01.22
TestReport=FileReport_AUDUSD_2010_01_22_00_59_37.htm
TestReplaceReport=true
TestShutdownTerminal=true

//------------------------------------------------------------------

ans SET file like this one :

<common>

positions=1

deposit=5000

currency=EUR

fitnes=1

genetic=0

</common>

<inputs>

Pourcent_Trade_Inverse=0.01700

Pourcent_Trade_Inverse,F=1

Pourcent_Trade_Inverse,1=0.0025

Pourcent_Trade_Inverse,2=0.0025

Pourcent_Trade_Inverse,3=0.04

Distance_Mini_Plus_HB=0

Distance_Mini_Plus_HB,F=1

Distance_Mini_Plus_HB,1=0

Distance_Mini_Plus_HB,2=50

Distance_Mini_Plus_HB,3=500

</inputs>

<limits>

balance_enable=1

balance=18750.00

profit_enable=0

profit=0

marginlevel_enable=0

marginlevel=0

maxdrawdown_enable=0

maxdrawdown=0

consecloss_enable=0

consecloss=0

conseclossdeals_enable=0

conseclossdeals=0

consecwin_enable=0

consecwin=0

consecwindeals_enable=0

consecwindeals=0

</limits>

I analyse the HTML report for optimize parameters. Since i have a lot of parameters, I have grouped them by 3 or 4, and a loop open Terminal in optimization mode with different SET file.

Unfortunately, after 2 ou 3 loops, the HTML file generated is no more sorted by Profit but ramdomely so it's a bit more difficult to read the best value in the HTML source.

any idea to what's happens or how to work around ?

thanks and apologise for my english ( french is easier for me !)

Phil

 
Personally I have my EA output a custom report file when optimizing. If you do that you would have full control on what's in it and on sorting... As for the built-in report file, I never experienced your problem.
 
gordon wrote >>
Personally I have my EA output a custom report file when optimizing. If you do that you would have full control on what's in it and on sorting... As for the built-in report file, I never experienced your problem.

Hi

How do you manage the result for each loop ? Writing data into csv file in the deinit() ?

As you can see, after a first good report, the other are not sorted anymore. Is there a parameter to force that ?

Passage Profit Total des Trades Facteur de profit Rémunération espérée Chute $ Chute %
1 682.66 17 1.17 40.16 4380.64 15.26
2 397.36 16 1.10 24.83 3686.12 13.30
3 -1970.62 19 0.60 -103.72 4322.62 16.55
4 546.86 16 1.14 34.18 2977.72 11.04
5 -1627.62 17 0.65 -95.74 3765.12 14.54
6 546.86 16 1.14 34.18 2977.72 11.04
7 800.86 16 1.19 50.05 3861.62 13.65

 
Matutin:

Hi

How do you manage the result for each loop ? Writing data into csv file in the deinit() ?

As you can see, after a first good report, the other are not sorted anymore. Is there a parameter to force that ?

Passage Profit Total des Trades Facteur de profit Rémunération espérée Chute $ Chute %
1 682.66 17 1.17 40.16 4380.64 15.26
2 397.36 16 1.10 24.83 3686.12 13.30
3 -1970.62 19 0.60 -103.72 4322.62 16.55
4 546.86 16 1.14 34.18 2977.72 11.04
5 -1627.62 17 0.65 -95.74 3765.12 14.54
6 546.86 16 1.14 34.18 2977.72 11.04
7 800.86 16 1.19 50.05 3861.62 13.65

Yeah, writing result to a file at deinit(), including all the custom calculations and stats I want in the report. The Report I use is in CSV file so later I can open via excel and then sorting/filtering becomes trivial.

Regarding your problem, I don't know of any way to force it. What u can do if u can't find a solution is to write a script to re-sort it or alternatively load it into excel and then u can sort very easily.

 

Many thanks

I was so proud to read into html result :) Let's remake all the job with CSV file !

 
Resolve by adding transfert HTML data in array and sorting by profit.
 

Unfortunately, after 2 ou 3 loops, the HTML file generated is no more sorted by Profit but ramdomely so it's a bit more difficult to read the best value in the HTML source.

First, click on a heading to sort the results.

 
WHRoeder wrote >>

First, click on a heading to sort the results.

Yes, but in an automatic mode with tester launched by MT4 itself....

 
WHRoeder:

First, click on a heading to sort the results.

Obviously, but Matutin is talking about launching the Terminal from command prompt using ini files and having the report automatically outputted and the Terminal terminate when the optimization is over. In this mode of operation if the user presses the heading then the Terminal will not auto-exit and will not auto save the report, which causes a problem if u r trying to automate the optimization process.

 

Matutin this may be too late to be of any assistance to you, but hopefully it can help any other would-be lurkers troubled with the auto-optimizer code...

The problem lies in an apparantly miscoded line of code in the auto-optimization include library. If you open your include file in metaeditor do a search for the following line of code:

ArraySort(ArrayTrans,StepRes,0,MODE_DESCEND);

The error here lies in the declaration that the the arraysort be done on only the first "StepRes" number of values in the array...for auto-optimizer the default value is twelve (12), so only the top 12 values of your auto-optimizer report are being used for down-selection.

To correct this, change the line of code to read:

ArraySort(ArrayTrans,WHOLE_ARRAY,0,MODE_DESCEND);
Save your include file and then recompile your EA for which you want to perform the auto-optimization. Auto-optimizer will now properly use all the tester generated data for sorting and parameter down-selection.
 

1005phillip wrote >>

[...] code in the auto-optimization include library.

What is that...?
Reason: