Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, ChrstphFr), 941 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 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,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

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