Discussion of article "Creating Custom Criteria of Optimization of Expert Advisors" - page 2

 

I have tested Kelly Criterion (Strategy), using the following code:


double OnTester(void)
  {
   //https://www.investopedia.com/articles/trading/04/091504.asp
   double w=((TesterStatistics(STAT_PROFIT_TRADES)+TesterStatistics(STAT_LOSS_TRADES))>0)?TesterStatistics(STAT_PROFIT_TRADES)/(TesterStatistics(STAT_PROFIT_TRADES)+TesterStatistics(STAT_LOSS_TRADES)):0; // winning probability
   double r=((TesterStatistics(STAT_GROSS_LOSS)!=0)&&(TesterStatistics(STAT_LOSS_TRADES)!=0)&&(TesterStatistics(STAT_PROFIT_TRADES)!=0))?(TesterStatistics(STAT_GROSS_PROFIT)/TesterStatistics(STAT_PROFIT_TRADES))/(-TesterStatistics(STAT_GROSS_LOSS)/TesterStatistics(STAT_LOSS_TRADES)):0; // Win/loss ratio;
   double Kelly=(r!=0)?w-((1-w)/r):0; // Kelly Criterion
   return(Kelly);
  }


I am not sure if Metatrader Strategy Tester computes 0 (zero) profit trades as profit trades. Anyone?

 
Ingvar Engelbrecht:

Well, here I am again, the lone wolf in this universe  :-)

I have been trying the straightness Custom Criteria trying to get the slope of the calculated straight line into the equation. As is it can give you a very hgh rating on a very feeble profit. Just adding the end profit

into the caculation does not make it any better  In an attempt to add the actual slope into the equation  I changed the code lilke seen below.

It is not a perfect solution but it is closer to what I want to see. Using result together wit balance or profit  works fine for me with this code


I know it's been so long since you posted this but in case you are still playing with this or someone else are looking for the same straightness criteria implementation.

I found a working public solution here https://community.darwinex.com/t/equity-curve-straigthness-optimization-with-metatrader/3976

Equity Curve Straigthness Optimization with Metatrader
Equity Curve Straigthness Optimization with Metatrader
  • 2018.05.16
  • KlondikeFX
  • community.darwinex.com
An underrated feature of Metatrader’s Backtester is its ability to define a custom fitness function for the genetic optimization process. Meaning that you no longer are limited to rather simple metrics like final balance or profit factor but can evaluate the quality of each test run with your own individual calculations. To give a quick...
 

The relating tutorial has too much info, such as specifically about programming an EA, which is in other tutorial, and non-applicable to average punter, who, will buy their EA and has minimal programming ability.

I find, that by default, the only useful criterions for MT5 in  genetic algo is the "balance max", then have to repeat that a few times, and fish through results til find low drawdown, as for use on multiple pairs.

What criterions I need :- Max balance with <20 Drawdown, MaxBalance with <10 Drawdown 

Reason: