21.4 C
San Juan
Sunday, March 8, 2026

Further code that data steadiness and fairness charts and calculates extra optimization standards. – Different – 26 January 2026


Connecting features for saving steadiness, fairness, and optimization statistics graphs for Superior Optimization Report

When you’ve got entry to the Knowledgeable Advisor code, you’ll be able to lengthen the report by including extra 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’ll be able to add it beneath the final line of your Knowledgeable Advisor code or wherever else)

#embrace 

Then, it’s essential add calls to the exported features to the present features in your Knowledgeable Advisor: (if there aren’t any features, 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’ll be able to add your personal standards that you just wish to embrace to the Superior Optimization Report.

For instance, let’s add this code to the Transferring Common Knowledgeable Advisor from the Examples folder (…MQL5ExpertsExamplesMoving AverageMoving Common.mq5). First, copy the unique Knowledgeable Advisor and identify it Transferring 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 

As you’ll be able to see, it is fairly easy and solely takes a few minutes.

After that, you’ll be able to run the optimization:

The final screenshot exhibits that the linked code added 2 parameters:

  1. Save Statistics – permits or disables the gathering of statistics
  2. Pixels in steadiness and fairness charts – specifies the variety of pixels within the width of mini-charts.

As soon as the optimization is full, you’ll be able to 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 will likely be displayed: 3 on prime and three on the underside.

It’s tough to understand 100 strains, so it’s essential use filters. Alternatively, you’ll be able to 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 an enumerator (enum), for instance: 1,2,3,5,7,10,15,20,30,50,70,100 – there will likely 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 Knowledgeable Advisor beneath.

As an alternative of 1000 optimization passes, there will likely be 120, and the calculation time will likely be ~8 instances quicker, and the file dimension will likely be ~8 instances smaller.
The result’s extra seen:

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

You may open and look at the ensuing report.

Related Articles

Stay Connected

0FansLike
0FollowersFollow
0SubscribersSubscribe
- Advertisement -spot_img

Latest Articles