MetaTrader 5 MT5 Libraries OptimReport v2.15 – library MetaTrader 5

OptimReport v2.15 – library MetaTrader 5

If you want to optimize your Expert Advisor using your own characteristics, you can use “Custom max” mode via OnTester() function.

This code simplifies to create your own formulae.

To define the custom optimization parameter, sometimes it’s necceary to calculate many trade characteristics.

This code provides you the following characteristics:

  1. Profit factor;
  2. Profit in deposit currency;
  3. Profit in points;
  4. Total Profit;
  5. Total Loss;
  6. Loss deals;
  7. Profitable deals;
  8. Profit per deal (in percents);
  9. Profit per day (in percents);
  10. Maximal drawdown;
  11. Balance channel width (in points);
  12. Difference between the maximal and minimal slope of the balance line;
  13. Average drawdown (averaged sum of drawdown for all deals);
  14. Recovery factor;
  15. Average points per deal.

Compared with previous version, I added the option to save optimization results (and all characteristics) to the HTML file.

OptimReport v2.15


Copy the “OptimReport.mqh” file to the MQL5\Include\ folder

Add the following line to the code of your Expert Advisor:

#include <OptimReport.mqh>
Add this line to OnInit() function:

Add this line to OnTick() function:


Add this line to the code when open position:

Alternative:   Display trade history on charts (MT5) - EA MetaTrader 5

Add these 4 lines to OnTester() function:

Input_Param="input"; // Input parameters here. See example below...
if(Crt_HTML) Sort_HTML_Ar();

Here is an example of Input_Param:

                  +" SL_B="+DoubleToString(SL_B,0)
                  +" GT_B="+DoubleToString(GT_B,0)
                  +" TS_B="+DoubleToString(TS_B,0);


The Lot_Risk variable is the percent of margin used in trading (for increasing volume).

Note that HTML file with optimization results is saved separately for each agent: С:\Program Files (x86)\MetaTrader 5\Tester\Agent-\MQL5\Files\

If you have found errors or need some other characteristics, please inform me.
It will be great if you provide your own optimization characteristics.

PS: I prefer to use the formula № 5

📈 ROBOTFX MetaTrader Expert Advisors and Indicators to maximize profits and minimize the risks