Optimal parameters for a basket of assets

Posted By: Brax

Optimal parameters for a basket of assets - 08/02/17 11:51

Hi,

As far as i am concerned, Zorro finds the best parameters for every algo/asset combination.

¿Is there a way i can obtain the best ones for the whole basket or even for every algo but for the whole basket again?

My point is to have a simple system over a basket of assets, where i apply it with the same parameters for all of them. Maybe not the optimal way of trading, but i am doing some research and i´d like to test it.
Posted By: jcl

Re: Optimal parameters for a basket of assets - 08/07/17 08:52

If the parameters are to be the same for all assets, then do not use the "loop" function for looping through assets, but a normal for() or while() loop. Optimize the parameters outside the loop.
Posted By: Brax

Re: Optimal parameters for a basket of assets - 08/07/17 10:17

Ok, thanks a lot.
Posted By: Brax

Re: Optimal parameters for a basket of assets - 08/14/17 10:33

Hi jcl,

I´ve been trying to do what you told me, but i think i am either doing something wrong or maybe it´s not possible to do with Zorro what i intended.

This is the code i´m testing.

Code:
static var opt_Filtered;
static var opt_Signal;
static var opt_Threshold;
static var opt_Stop_Cntr;
	
function tradeCounterTrend()
{
	vars Price = series(priceClose());
	vars Filtered = series(BandPass(Price,opt_Filtered,0.5));
	vars Signal = series(Fisher(Filtered,opt_Signal));
	var Threshold = opt_Threshold;
	
	Stop = opt_Stop_Cntr * ATR(10);
	Trail = 4*ATR(10);
	
	if(crossUnder(Signal,-Threshold))
		enterLong(); 
	else if(crossOver(Signal,Threshold)) 
		enterShort();
}

function run()
{
	set(LOGFILE+PARAMETERS);
	NumCores = -2;
	BarPeriod = 24*60;
	LookBack = 500;
	StartDate = 2005;
	EndDate = 2015;
	Capital = 10000;
	
	if(ReTrain) {
		UpdateDays = -1;
		SelectWFO = -1;	
		reset(FACTORS);	
	}

	// Parameters	
	opt_Filtered = optimize(30,20,40,1);
	opt_Signal = optimize(10,5,20,1);
	opt_Threshold = optimize(1,0.5,1.5,0.1);
	opt_Stop_Cntr = optimize(4,2,10,1); 
	
	int i;
	string assets[2];
	assets[0] = "EUR/USD";
	assets[1] = "USD/JPY";
	
	for(i=0;i!=2;i++){
		asset(assets[i]);
		Lots = 5;
		tradeCounterTrend();	
	}
			
	PlotWidth = 1024;
	PlotHeight1 = 400;
}



When i run this, it seems that Zorro is optimizing only for the last asset, and then it aplies those parameters for the two of them.

I suspect this, because if i do it the loop way i can see the parameters given are those for USDJPY in this case.

Probably i´m doing something wrong. My idea was to obtain a set of parameters optimized for the whole basket, that is, those that get a decent result for all the set, not just for one of them an then applying the same parameters for the rest.

It is a kind of global optimization, not one by one and then summing up all equities.
Posted By: jcl

Re: Optimal parameters for a basket of assets - 08/15/17 17:54

I thought that was just what you wanted to do - optimizing parameters that are not for one, but common for all assets.

If not, use a loop and put the optimize calls inside. Then you get individual parameters for any asset. Parameters can be either common or individual, but obviously not both at the same time.
Posted By: Brax

Re: Optimal parameters for a basket of assets - 08/16/17 10:25

Yes, what you first told me was right. It´s only the result was not exactly what i expected.

Anyway, i think it suited my purpose.

Thanks a lot.
© 2024 lite-C Forums