Hello, I am trying to optimize a system for the lowest correlation to EC of
another system but have difficulties with the custom metric. Below is the code
I have so far. Is someone able to modify it to achieve some results?
Thank you.
SetCustomBacktestProc("");
if( Status("action") == actionPortfolio )
{
bo = GetBacktesterObject();
bo.Backtest();
st = bo.GetPerformanceStats(0);
ReferenceSystemEQ=Foreign("simple45","C");
ReferenceSystemEQNorm=ReferenceSystemEQ-Ref(ReferenceSystemEQ,-1);
CurrentEquity=bo.Equity();
CurrentEquityNorm=CurrentEquity-Ref(CurrentEquity,-1);
R=Correlation(ReferenceSystemEQNorm,CurrentEquityNorm,BarCount);
bo.AddCustomMetric( "R", R);
}