Connecting capabilities for saving stability, fairness, and optimization statistics graphs for Superior Optimization Report
If in case you have entry to the Skilled Advisor code, you may lengthen the report by including further code.
Obtain the Superior Optimization Report Saver.mqh file from hooked up hyperlink beneath and put it aside to the terminal folder MQL5Include
Add the code that connects the downloaded file: (you may add it beneath the final line of your Skilled Advisor code or anyplace else)
#embrace <Superior Optimization Report Saver.mqh>Then, that you must add calls to the exported capabilities to the present capabilities in your Skilled Advisor: (if there are not any capabilities, add them)
void OnTick(){ Â Â Â Â Â Â Â Â save_OnTick(TimeCurrent(), AccountInfoDouble(ACCOUNT_BALANCE), AccountInfoDouble(ACCOUNT_EQUITY)); } void OnTesterInit()Â Â { Â Â Â Â save_OnTesterInit(); } void OnTesterDeinit(){ Â Â Â Â Â Â save_OnTesterDeinit(); } double OnTester(){ Â Â Â Â Â Â double AvgPips=0; Â Â save_Add( AvgPips, 2, "Customized 1", true); Â Â save_Add( TesterStatistics( STAT_PROFIT ), 2, "Customized 2"); Â Â double Customized = 0; Â Â saveCharts(Customized); Â Â return Customized; }
Within the highlighted space, you may add your personal standards that you simply need to embrace to the Superior Optimization Report.
For instance, let’s add this code to the Shifting Common Skilled Advisor from the Examples folder (…MQL5ExpertsExamplesMoving AverageMoving Common.mq5). First, copy the unique Skilled Advisor and identify it Shifting Common Charts.mq5. Now, add the code from the directions above to it.
The modifications are solely on the very finish of the code, ranging from the OnTick() operate:
void OnTick(void)   {   if(SelectPosition())       CheckForClose();   else       CheckForOpen();     save_OnTick (TimeCurrent(), AccountInfoDouble( ACCOUNT_BALANCE), AccountInfoDouble( ACCOUNT_EQUITY));   } void OnTesterInit()  {     save_OnTesterInit(); } void OnTesterDeinit(){       save_OnTesterDeinit(); } double OnTester(){       double AvgPips=0;   save_Add( AvgPips, 2, "Customized 1", true);   save_Add( TesterStatistics( STAT_PROFIT ), 2, "Customized 2");   double Customized = 0;   saveCharts(Customized);   return Customized; } #embrace <Superior Optimization Report Saver.mqh>
As you may see, it is fairly easy and solely takes a few minutes.
After that, you may run the optimization:


The final screenshot exhibits that the linked code added 2 parameters:
- Save Statistics – permits or disables the gathering of statistics
- Pixels in stability and fairness charts – specifies the variety of pixels within the width of mini-charts.
As soon as the optimization is full, you may create a report and see the next:
100Â strains with MovingPeriod | 10Â strains with MovingShift |
If there are greater than 20 strains, solely 3 horizontal strains of common values might be displayed: 3 on high and three on the underside.
It’s tough to understand 100 strains, so that you must use filters. Alternatively, you may resize the chart to 100% of the display width or click on on the chart to open it in Google Charts, which lets you zoom utilizing the mouse wheel.
It’s even higher to make use of enter variables not with the identical step, however with a scale by means of an enumerator (enum), for instance: 1,2,3,5,7,10,15,20,30,50,70,100 – there might be solely 12 strains as a substitute of 100.
enum nums1 {__0=0, __1=1, __2=2, __3=3, __5=5, __7=7, __10=10, __15=15, __20=20, __30=30, __50=50, __70=70, __100=100, __150=150, __200=200, __300=300, __500=500}; enter nums1 MovingPeriod = 10;
You may obtain the enum model of the Skilled Advisor beneath.
As an alternative of 1000 optimization passes, there might be 120, and the calculation time might be ~8 instances quicker, and the file dimension might be ~8 instances smaller.
The result’s extra seen:

The consequence with MovingPeriod = 15 stands out instantly, with the very best common line and the very best most.
Nevertheless, as is commonly the case, the perfect outcomes on the backtest are usually not the perfect on the ahead take a look at:

You may open and study the ensuing report.

