Easy way to add "custom max" criteria to your optimizations
-
I know this has been talked about before but considering the recent update to the optimization criteria in Strategy Tester for MT5 I figured I'd share an easy way to add custom max criteria to your EAs.
Open MetaQuotes Language Editor (or hit F4) then click crtl + F to find the words "custom functions" in the code. Past your OnTester() function in this section under the header. For instance I prefer to optimize to max balance multiplied by max profit factor. The code I use looks like this:

Now all you need to do is select "custom max" as your optimization criteria and it will optimize your EA according to this function.
Re: onTester()
-
@chance4373 Interesting information. Thank you.
-
Great article. Would you know how to write the code to make the custom max be balance max + recovery factor max? Thanks.