I was able to do global optimization bringing the optimize() call prior to any for loops. However I am still struggling with how to optimize "per pair".

I have now tried this... For instance the PAIRLOOP contains "BBHFAZ","BBHGDX".... Then the string is split into the two asset symbols a1/a2.
Code
	string pair;
	while(pair = loop(PAIRLOOP))
	{
		Algo = pair;
		//string pair = dataStr(10,i,1);
		
		string a1 = strmid(pair,0,3);
		string a2 = strmid(pair,3,3);	
		
		tradePair(a1,a2);
	}



Code
void tradePair(string a1, string a2)
{
	int _stochPer = optimize(8,8,20,2);
	int _stochPer = optimize(8,8,20,2);
	var _th = optimize(50,35,95,5);
	int _hurstPer = 60;//round(optimize(40,20,70,10));
	var _hurstTh = 0.5;//optimize(0.5,0.3,0.8,0.1);
	int _atrPer = 20;//round(optimize(10,5,50,5));
	var _minCorr = 0;//optimize(0,0,0.5,0.1);
	int _corrPer = 100;
	
	SetMargin();
	MaxLong = MaxShort = 1;
	var thH = _th;
	var thL = -thH;
	
	asset(a1);
	vars p1 = series(priceClose());

	asset(a2);
	vars p2 = series(priceClose());
        .........
}



This seems to work but still has problems. I get stuff like this...

BBH:BBHFAZ 12.00 11.95 45.3=> 3.416
BBH:BBHGDX 12.00 16.27 44.2=> 2.132
BBH:BBHGLD 12 10.19 55.0=> 1.526
BBH:BBHSDS 12 13.76 54.3=> 5.327
BBH:BBHTLT 12 10.32 59.9=> 1.957
BBH:BBHTZA 12 10.21 60.2=> 3.145
BBH:BBHVXX 12.00 9.93 45.0=> 1.147
BBH:BBHXLU 12 16.11 65.0=> 6.489
BBH:DIAFAZ 8 8 50=> 0.000
BBH:DIAGDX 12 16.13 44.7=> 0.982
BBH:DIASDS 8 8 50=> 0.000
BBH:DIATZA 8 8 50=> 0.000



I have thought of setting Asset="BBHFAZ"; and listing them on the AssetList as dummies. But I am thinking the individual Asset="a1" calls later defeat the purpose.

Last edited by jbhunter; 06/14/20 03:29.