Thank you JCL, for your reply.

Please pay attention that there is ONE global parameter, so if I use your suggestion - no parameters train would take place.

Code
function run()
{

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

	asset("AGG");
	int Max_Long_Assets = optimize(2,1,4,1);
//	int Max_Long_Assets = 2;

	
	while(asset(loop(Assets))) {
		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);
		var Threshold2  = optimize(0.05,0.0,0.1,0.01);
		int RR  = signal1 - signal2 <  Threshold1;
		int TT  = signal1 - signal2 >= Threshold2;
//		printf("\n%.3f %.3f",sma5,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();
//	plot("TT",signal1 - signal2,NEW|LINE,RED);
	}
	
}



Zorro's train run results:

Code

XLV history up to date
XLV 3967 ticks read
Loop[8] p1 step  1:  0.00 => 0.00   0/ 0

Loop[8] p2 step  1:  0.00 => 0.00   0/ 0

XLV: 0.050 0.050=> 0.000

Parameters stored in David.par




If I disable the global parameter, then the train works OK

Code

//	int Max_Long_Assets = optimize(2,1,4,1);
	int Max_Long_Assets = 2;  // No global parameter



Code
Loop[8] p2 step  7:  0.06 => 0.72  460/651
Loop[8] p2 step  8:  0.07 => 0.72  461/649
Loop[8] p2 step  9:  0.08 => 0.72  459/649
Loop[8] p2 step 10:  0.09 => 0.73  460/646
Loop[8] p2 step 11:  0.10 => 0.73  458/645
Selected p2[9] = 0.080  => 0.73

XLV: 0.070 0.080=> 0.723

Parameters stored in David.par



The only way I succeeded to optimize ONE global and TWO local parameters , is using "listed_assets", but it works for 7 assets only.