Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (1 invisible), 672 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 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,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
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