"Lowest Margin Seen in %" as custom optimization criterion
Could you add an extra value in the DropDown menu, and the following piece of code (or similar) to allow exporting the "Lowest Margin Seen in %" during the backtest as the OnTester return value?
cp-margin-level-min.png
During the backtests, MT4/MT5 store this information in the variable "TesterStatistics(STAT_MIN_MARGINLEVEL)", see readme here
So that's an example of code that I use in my EAs:
=====
double OnTester() {
<...> // existing code
else if (InpEquityRecorderType == 2) // or any other enum integer that would match the value in the dropdown menu
return (TesterStatistics(STAT_MIN_MARGINLEVEL));
}
}
=====
Thanks !
Sure, this could be helpful!