Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Nymphodora), 972 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Asset specific parameters #478531
11/04/19 00:55
11/04/19 00:55
Joined: Oct 2018
Posts: 70
AZ
C
chsmac85 Offline OP
Junior Member
chsmac85  Offline OP
Junior Member
C

Joined: Oct 2018
Posts: 70
AZ
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.

Re: Asset specific parameters [Re: chsmac85] #478537
11/04/19 10:58
11/04/19 10:58
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
I see no loop call in your script. You must really call loop(), not for(). Check out workshop 6 about portfolio systems.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1