Here jcl described how to override the default objective function that is declared in include\default.h -by the way, there it is commented that it optimizes based on the Pessimistic Return Ratio not the Profit Factor-

Click to reveal..

Code:
// optimizing objective based on PRR
var objective()
{
	if(!NumWinTotal && !NumLossTotal) return 0.;
	var wFac = 1./sqrt(1.+NumWinTotal); 
	var lFac = 1./sqrt(1.+NumLossTotal);
	var win = WinTotal, loss = LossTotal;
// remove single outliers
	if(NumWinTotal > 2) win -= (NumWinTotal-2)*WinMaxTotal/NumWinTotal;
	if(NumLossTotal > 2) loss -= (NumLossTotal-2)*LossMaxTotal/NumLossTotal;
// return PRR
	return (1.-wFac)/(1.+lFac)*(1.+win)/(1.+loss);
}




Concerning optimizing for SR, I think you can use the data in the PERFORMANCE struct inside the GLOBALS struct, both are defined in include\trading.h, inside the GLOBALS struct there is a PERFORMANCE * w variable

Also as you can see in include\default.c there is this line:

Code:
extern GLOBALS* g; // global variables struct



which means that whatever script that is including default.c will have a variable g to access the global variables. Since Sharpe Ratio in Zorro is simply Mean Profit / Std of Profits I think you can do something like

Code:
var optimize(){
    return g->w->vMean / g->w->vStd;
}



I hope this helps, I explained it a bit step by step to help others that are reading this thread and are not introduced to coding.