Asset specific parameters

Posted By: chsmac85

Asset specific parameters - 11/04/19 00:55

I've read the manual (https://manual.zorro-project.com/optimize.htm) regarding how to set two parameters but I can't seem to write the code correctly. I'll paste snippets with my interpretation after.

In portfolio strategies, parameters must be normally optimized individually for any component. For this use one or two loop calls to cycle through assets and algos. I have one algo but many assets so this should be done in a single loop

All optimize calls must be inside the inner loop. The asset and algo must be selected before calling optimize. I think I select the asset after calling TakeProfit and Stop

For optimizing asset- or algo-independent parameters in a portfolio system, call optimize outside the loop, but select an asset before calling optimize. I think this is where I am wrong. I don't know what this means.

If individual optimization is not desired, don't use loop, but enumerate the assets in a simple for loop, f.i. for(used_assets) ..., and optimize the parameters outside the for loop. Make sure in that case to select all assets before the first optimize call; otherwise the optimizier will assume a single-asset strategy.


Faulty code below.
Code

function run()
{

	StartDate = 2010;
	EndDate = 2019; // fixed simulation period 2010-2019
	BarPeriod = 480;	// 8 hour bars
	LookBack = 500;
	set(PARAMETERS);


assetList(ASSETLIST);
		for(listed_assets){
		TakeProfit = optimize(30, 0, 50, 1) * PIP; 
		Stop = optimize(150, 0, 50, 1) * PIP;
		asset(Asset);
		vars aPrice = series(price());
		vars aFiltered = series(BandPass(aPrice,30,0.5));
		vars Signal = series(FisherN(aFiltered,500));
		var Threshold = 1.0;

				
		// buy and sell
	if(crossUnder(Signal,-Threshold))
		enterLong();
	else if(crossOver(Signal,Threshold))
		enterShort(); 
		}


If i move the optimize call outside the for loop, it sets global stops and take profits.
Posted By: jcl

Re: Asset specific parameters - 11/04/19 10:58

I see no loop call in your script. You must really call loop(), not for(). Check out workshop 6 about portfolio systems.
© 2024 lite-C Forums