Gamestudio Links
Zorro Links
Newest Posts
DirectX : 3d Hardware Reset Failure
by Emre. 11/27/20 11:06
Sortino(vars Data, int TimePeriod): var
by danatrader. 11/26/20 20:45
Need code for Williams Sentiment Index
by danatrader. 11/26/20 20:42
Binance Futures Plugin
by Mio. 11/26/20 10:54
Optimizing global & local parameters
by dBc. 11/25/20 15:16
Enter FOK orders simultaneously
by jcl. 11/25/20 10:55
looking how basic functions are made
by jcl. 11/25/20 10:47
AUM Magazine
Latest Screens
Paradox Vector
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
Who's Online Now
6 registered members (AndrewAMD, danatrader, 3run, jumpman, NnamueN, 1 invisible), 483 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
MMK, raed, liquidbread, Dmitry_Shesterin, ddczp
18543 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Optimize in a ranked asset portfolio [Re: dBc] #481738
10/24/20 19:20
10/24/20 19:20
Joined: Jan 2017
Posts: 10
Israel
D
dBc Offline OP
Newbie
dBc  Offline OP
Newbie
D

Joined: Jan 2017
Posts: 10
Israel
danatrader thanks again for your reply

I looked at "Petra on Programming: Four Dimensions of Strength" and I got the response I looked for.

Here is the updated code:
Code
function run()
{
	set(PARAMETERS+LOGFILE+PLOTNOW);
//	set(LOGFILE+PLOTNOW);
	BarPeriod    = 1440;
	LookBack     = 120;
	Verbose      = 0;
	var Weights[6];
	string Stocks[6];
        Capital = 10000;
//	NumWFOCycles = 5;
	
	
	
	while(asset(loop(""MDY", "TLT", "EEM", "ILF", "EPP", "FEZ"")))
	{
		Returns[Itor1] = RET(optimize(60,20,120,20));
		Stocks[Itor1]  = Loop1;
	}
	
	
	if (month(0) != month(1)) { // once a month do
		int i;
		distribute(Weights,Returns,6,1,0);

		for(i=0;i<6;i++) {

			asset(Stocks[i]);
			int NewShares = Weights[i]*Balance/priceClose(0) - LotsPool;

			if(NewShares > 0)
				enterLong(NewShares);
			else if(NewShares < 0)
			        exitLong("",-NewShares);
		}
	}

}




This code optimizes each asset separately as expected

Re: Optimize in a ranked asset portfolio [Re: dBc] #481748
10/26/20 14:34
10/26/20 14:34
Joined: Oct 2017
Posts: 36
Munich
K
kalmar Offline
Newbie
kalmar  Offline
Newbie
K

Joined: Oct 2017
Posts: 36
Munich
Hi dBc,

And what is RET() in your "Returns[Itor1] = RET(optimize(60,20,120,20));" means? Is your self-made function for return calculation?

Thx

Re: Optimize in a ranked asset portfolio [Re: dBc] #481749
10/26/20 15:08
10/26/20 15:08
Joined: Mar 2019
Posts: 338
D
danatrader Online
Senior Member
danatrader  Online
Senior Member
D

Joined: Mar 2019
Posts: 338
https://zorro-trader.com/manual/en/ta.htm

RET(int TimePeriod): var
Return of the current asset: (Close(0)-Close(TimePeriod))/Close(TimePeriod). Source code in indicators.c

Re: Optimize in a ranked asset portfolio [Re: dBc] #481750
10/26/20 16:50
10/26/20 16:50
Joined: Oct 2017
Posts: 36
Munich
K
kalmar Offline
Newbie
kalmar  Offline
Newbie
K

Joined: Oct 2017
Posts: 36
Munich
Sorry, Thx danatrader laugh I was searching for "RET(" and got nothing

Re: Optimize in a ranked asset portfolio [Re: dBc] #481751
10/26/20 17:18
10/26/20 17:18
Joined: Oct 2017
Posts: 36
Munich
K
kalmar Offline
Newbie
kalmar  Offline
Newbie
K

Joined: Oct 2017
Posts: 36
Munich
Hi, dBc,

I guess this line "if (month(0) != month(1)) { // once a month do" could be also changed to "if(tdm() == 1 && !is(LOOKBACK)){ // 1st trading day of the month"

Re: Optimize in a ranked asset portfolio [Re: dBc] #481755
10/27/20 06:33
10/27/20 06:33
Joined: Jan 2017
Posts: 10
Israel
D
dBc Offline OP
Newbie
dBc  Offline OP
Newbie
D

Joined: Jan 2017
Posts: 10
Israel
Hi Kalmar,

I copied the code from "Petra on programing", but probably you can use if(tdm()==1 .... as well. I'm very new user of this amazing software.

Page 2 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1