Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by M_D. 04/26/24 20:22
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 839 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
How to perform portfolio optimization? #482678
03/16/21 20:08
03/16/21 20:08
Joined: Mar 2021
Posts: 24
A
antoniorenar Offline OP
Newbie
antoniorenar  Offline OP
Newbie
A

Joined: Mar 2021
Posts: 24
Good afternoon,
I am new in zorro,
I am trying to optimize my system on multiple symbols and that single set of parameters for all symbols but at the moment it throws me a set of parameter for each symbol that I optimize, someone who does the same could give me a hint

Last edited by antoniorenar; 03/16/21 21:05.
Re: How to perform portfolio optimization? [Re: antoniorenar] #482679
03/16/21 20:12
03/16/21 20:12
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
What is your question?

Re: How to perform portfolio optimization? [Re: antoniorenar] #482680
03/16/21 21:04
03/16/21 21:04
Joined: Mar 2021
Posts: 24
A
antoniorenar Offline OP
Newbie
antoniorenar  Offline OP
Newbie
A

Joined: Mar 2021
Posts: 24
I want to optimize my system in several markets at the same time, and that the optimizer looks for a single set of parameters for all markets
not one for each
can you show me some code?
Thanks for your answer

Last edited by antoniorenar; 03/16/21 21:05.
Re: How to perform portfolio optimization? [Re: antoniorenar] #482681
03/16/21 21:22
03/16/21 21:22
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Can you give me an example of code that does what you do not expect/want and explain what you expect/want instead?

Re: How to perform portfolio optimization? [Re: antoniorenar] #482684
03/17/21 00:20
03/17/21 00:20
Joined: Mar 2021
Posts: 24
A
antoniorenar Offline OP
Newbie
antoniorenar  Offline OP
Newbie
A

Joined: Mar 2021
Posts: 24
For instance, the algorithm below optimizes a couple of parameters (TimeFactor and Coef) in the EUR/USD, GBP/USD and AUD/USD symbols. As a result, the best couple of parameters is 3.45 and 2.90 in EUR/USD, 3.64 and 8.01 in GBP/USD, and 3.59 and 8.10 in AUD/USD.
However, if my code would run as I want, we would obtain the same parameters for the 3 symbols (for example, 3.5 and 5 for EUR/USD, GBP/USD and AUD/USD markets). This is an example of multi-symbol algorithm. In this way the optimization look for the same set of parameter for different markets in order to get the best trading results combining the same algorithm with the same parameters in different markets.


function run()
{
set(LOGFILE);
set(PARAMETERS);

StartDate=2018;
NumYears=1;

BarPeriod = 60;
LookBack = 100*5;

while( asset( loop("EUR/USD","GBP/USD","AUD/USD") ) )
{
var TimeFactor = optimize(3,1,5,1);
var Coef = optimize(3,1,10,1);

vars Price = series(price(0));
vars MA1 = series(SMA(Price,30));
vars MA2 = series(SMA(Price,30*TimeFactor));

Stop = Coef*ATR(10);

if(crossOver(MA1,MA2))
enterLong();
else if(crossUnder(MA1,MA2))
enterShort();
}
}

Re: How to perform portfolio optimization? [Re: antoniorenar] #482685
03/17/21 01:12
03/17/21 01:12
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
You move your optimize() calls to outside of the while asset loop. Now instead of six optimized variables, you get two optimized variables, which will then be common to all assets.

Re: How to perform portfolio optimization? [Re: antoniorenar] #482692
03/17/21 17:08
03/17/21 17:08
Joined: Mar 2021
Posts: 24
A
antoniorenar Offline OP
Newbie
antoniorenar  Offline OP
Newbie
A

Joined: Mar 2021
Posts: 24
I try whit this code, nevertheless it keeps throwing me 6 parameters
Could you help me correcting the fragment and sending it to me?

function run()
{
set(LOGFILE);
set(PARAMETERS);

StartDate=2018;
NumYears=1;

BarPeriod = 60;
LookBack = 100*5;

var TimeFactor = optimize(3,1,5,1);
var Coef = optimize(3,1,10,1);

while( asset( loop("EUR/USD","GBP/USD","AUD/USD") ) )
{
vars Price = series(price(0));
vars MA1 = series(SMA(Price,30));
vars MA2 = series(SMA(Price,30*TimeFactor));

Stop = Coef*ATR(10);

if(crossOver(MA1,MA2))
enterLong();
else if(crossUnder(MA1,MA2))
enterShort();
}
}

Thanks a lot for your time, I hope to reward you

Re: How to perform portfolio optimization? [Re: antoniorenar] #482693
03/17/21 17:33
03/17/21 17:33
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
I forgot to mention - you need to eliminate the loop() call. For that, you can load an asset list and use one of the asset loops instead:
https://manual.zorro-project.com/fortrades.htm

Re: How to perform portfolio optimization? [Re: AndrewAMD] #482695
03/17/21 23:51
03/17/21 23:51
Joined: Mar 2021
Posts: 24
A
antoniorenar Offline OP
Newbie
antoniorenar  Offline OP
Newbie
A

Joined: Mar 2021
Posts: 24
Sorry, I've been in zorro for two days and I can't find the function correctly, would you do me the immense favor of editing the code in the right way, thanks you

Re: How to perform portfolio optimization? [Re: antoniorenar] #482696
03/17/21 23:54
03/17/21 23:54
Joined: Mar 2021
Posts: 24
A
antoniorenar Offline OP
Newbie
antoniorenar  Offline OP
Newbie
A

Joined: Mar 2021
Posts: 24
function run()
{
set(LOGFILE);
set(PARAMETERS);

StartDate=2018;
NumYears=1;

BarPeriod = 60;
LookBack = 100*5;

var TimeFactor = optimize(3,1,5,1);
var Coef = optimize(3,1,10,1);

while( asset( loop("EUR/USD","GBP/USD","AUD/USD") ) )
{
vars Price = series(price(0));
vars MA1 = series(SMA(Price,30));
vars MA2 = series(SMA(Price,30*TimeFactor));

Stop = Coef*ATR(10);

if(crossOver(MA1,MA2))
enterLong();
else if(crossUnder(MA1,MA2))
enterShort();
}
}

Page 1 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1