I'm trying to optimize the following strategy, which has one global and two local parameters.

The optimization process runs OK when there are up to 7 assets. When I add the 8 and up assets I got the:

"Error 011: optimize(invalid parameters)"

I tied to debug with watch() and diag.txt, but nothing comes up.

Any help will be appreciated.

This is the code:
Code
function run()
{

	set(PARAMETERS|LOGFILE);
	BarPeriod    = 1440;
	StartDate     = 2010;
	LookBack    = 100;
	Verbose      = 7;
	assetList("AssetsZ9.csv");

	asset("AGG");
	int Max_Long_Assets = optimize(2,1,4,1);  //global optimization parameter
	
	for(listed_assets) {
		asset(Asset);
		vars Prices     = series(price());
		var  sma5       = ROC(Prices,5);
		
		var signal1     = SMA(Prices,5);
		var signal2     = SMA(Prices,30);
		var Threshold1  = optimize(0.05,0.0,0.1,0.01);  // local optimization parameter
		var Threshold2  = optimize(0.05,0.0,0.1,0.01);  // local optimization parameter
		int RR  = signal1 - signal2 < Threshold1;
		int TT  = signal1 - signal2 > Threshold2;
//		printf("\n%.3f",signal1 - signal2);
		
		
		int In = (sma5<0 && RR==1) || (sma5>0 && TT==1);
		int Out= (sma5>0 && RR=1) || (sma5<0 && TT==1);
		
		int NewShares = Balance/priceClose(0)/Max_Long_Assets-LotsPool;
		
		if(In && NumLongTotal < Max_Long_Assets)
			enterLong(NewShares);
		else if (Out)
			exitLong();
	}
	
}


Last edited by dBc; 11/14/20 16:04.