Сode that records balance and equity charts and calculates additional optimization criteria
I decided to share the code from a large project designed in a separate library.
If you have access to the Expert Advisor code, you can save balance and equity charts and calculate additional optimization criteria by adding additional code from this library.Download the Advanced Optimization Report Saver.mqh file from attached link and save it to the terminal folder \MQL5\Include\Add the code that connects the downloaded file: (you can add it below the last line of your Expert Advisor code or anywhere else)
Then, you need to add calls to the exported functions to the existing functions in your Expert Advisor: (if there are no functions, add them)
save_Add functions, allow you to add your own criteria that you want to include to your Report:
For example, let's add this code to the Moving Average Expert Advisor from the Examples folder (...\MQL5\Experts\Examples\Moving Average\Moving Average.mq5). First, copy the original Expert Advisor and name it Moving Average Charts.mq5. Now, add the code from the instructions above to it.The changes are only at the very end of the code, starting from the OnTick() function after CheckForOpen(); line:
As you can see, it's quite simple and only takes a couple of minutes.After that, you can run the optimization:
The last screenshot shows that the connected code added 2 parameters:
- Save Statistics - enables or disables the collection of statistics
- Pixels in balance and equity charts - specifies the number of pixels in the width of mini-charts.
Once the optimization is complete, you can create a report (using a program that parses saved frames) and see the following:
If there are more than 20 lines, only 3 horizontal lines of average values will be displayed: 3 on top and 3 on the bottom.100 lines are difficult to perceive, so you need to reduce their number.You to use input variables not with the same step, but with a scale through an enumerator (enum), for example: 1,2,3,5,7,10,15,20,30,50,70,100 - there will be only 12 lines instead of 100.
You can download the enum version of the Expert Advisor from attached files.Instead of 1000 optimization passes, there will be 120, and the calculation time will be ~8 times faster, and the file size will be ~8 times smaller.The result is more visible:
The result with MovingPeriod = 15 stands out immediately, with the highest average line and the highest maximum.However, as is often the case, the best results on the backtest are not the best on the forward test.Your program that parses saved frames can display Charts like this:
And additional criteria like this:
If you have a code for other interesting criteria, you can suggest them for adding to the library.