Hi,

I am currently doing some research on optimization criteria and i´ve got stuck trying to apply LinearRegSlope*R2 to optimize parameters.

This code gives me an error regarding i need more lookback period:

Code:
var objective()
{
    return LinearRegSlope(ResultsDaily,Bar-StartBar)*R2;   	
}



I´ve also tried with Day instead of Bar-StarBar, and even putting directly a number lower than lookback for the period gets a crush.

¿How could i achieve this?

The alternative is using (WinTotal-LossTotal)*R2, but this is not what i really want.