You are welcome! I myself got enthusiastic with your idea, I have been thinking about optimizing more than one trade statistic. First one clarification about optimizing, generally if you want to minimize/maximize a value you can just return it or the negative of it, ie if you want to minimize the ulcer index alone that would be
Code:
return -1 * perf->vUlcer;


since you want it to be as small as possible. But since Zorro does not search for the max but for the 'broader peak' in this case if there are negative values in the result I don't know if it is going to pick the 'broader valley', so it is better to return the reciprocal,
Code:
if (perf->vUlcer == 0)
    return 9999999999;// just return the max float or var value
else
    return 1 / perf->vUlcer;


If you want to optimize more than one and the one you want to minimize is always equal or greater than 0 -you don't want (-1)*(-something) become positive laugh - you can still substract it, like:
Code:
//optimize sharpe ratio and ulcer index
var sharpe_ratio = perf->vMean / perf->vStd;
return sharpe_ratio - perf->vUlcer;


but again I doubt Zorro will find the broader peak, for instance if you have this Sharpe Ratios and Drawdowns (invented)
Code:
SR	DD
0.7	7000
0.5	1500
0.7	1000
1.2	2000
1.5	3500
1	500
2	1000
3.5	7000
2.5	689
3	700
2.9	110
-0.8	2500


Then all values in the performance charts will be negative, on the other hand if objective is:
Code:
//optimize sharpe ratio and drawdown
var sharpe_ratio = perf->vMean / perf->vStd;
if (perf->vDrawDown == 0)
    return 9999999999;
else
    return sharpe_ratio / perf->vDrawDown;


Then most of the values will be positive and Zorro will search for the broader peak as it is documented.

PS: I remember a post about modifying the optimize/objective function so that it returned the highest peak instead of the broader one, I have been searching the forum to no avail maybe someone remembers it.

Last edited by Mithrandir77; 04/25/16 02:54. Reason: not sharpe_ratio / perf->vDrawDown == 0 but perf->vDrawDown == 0