2 registered members (firecrest, AndrewAMD),
387
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Asset list
[Re: Brax]
#467941
09/08/17 21:10
09/08/17 21:10
|
Joined: Feb 2017
Posts: 1,725 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,725
Chicago
|
Like this?
int i,j;
string as[2], al[2];
as[0] = "EUR/USD";
as[1] = "USD/JPY";
al[0] = "TRND";
al[1] = "CNTR";
// portfolio loop
while(asset(loop(as[0],as[1])))
while(algo(loop(al[0],al[1])))
{
if(Asset == as[0]) i=0; // etc
if(Algo == al[0]) j=0; // etc
}
Last edited by AndrewAMD; 09/08/17 21:31.
|
|
|
Re: Asset list
[Re: AndrewAMD]
#467957
09/10/17 20:41
09/10/17 20:41
|
Joined: Aug 2017
Posts: 102 Spain
Brax
OP
Member
|
OP
Member
Joined: Aug 2017
Posts: 102
Spain
|
Well, not really... The point is not having to repeat the listing in array initialization, loops, an so on. I think, given the tools that zorro provides, the best option it´s just using a for loop and using the index for selecting assets and avoiding switch statements.
int i,j;
string as[2], al[2];
int lt[2];
as[0] = "EUR/USD";
as[1] = "USD/JPY";
al[0] = "TRND";
al[1] = "CNTR";
lt[0] = 10;
lt[1] = 20;
// portfolio loop
for(i=0;i!=2;i++)
{
asset(as[i]);
Lots = lt[i]; //Avoiding switchs
for(j=0;j!=2;j++)
{
algo(al[j]);
if(algo == "CNTR")
tradeCounterTrend();
elseif(algo == "TRND")
tradeTrend();
}
}
|
|
|
Re: Asset list
[Re: Brax]
#467958
09/11/17 00:40
09/11/17 00:40
|
Joined: Feb 2017
Posts: 1,725 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,725
Chicago
|
Did you know that the loop() function serves a special purpose for Zorro, particularly for portfolio trading? Sure, a for loop will cycle you through the assets, but now your portfolio functionality is gone! (See workshop 6: Portfolio Trading) One other approach would be to create a custom asset list csv and invoke it with assetList, and then determine which number of asset you are on with LoopNum1 or LoopNum2. But definitely consider using loop() when portfolio trading.
|
|
|
Re: Asset list
[Re: AndrewAMD]
#467965
09/11/17 10:03
09/11/17 10:03
|
Joined: Aug 2017
Posts: 102 Spain
Brax
OP
Member
|
OP
Member
Joined: Aug 2017
Posts: 102
Spain
|
Yes, i´ve always used loop() in my scripts, using for() was just a "solution" for my addressed question.
I hadn´t realized about Loop1 and LoopNum1, but then the point would be to define Assets directly in the script, not in a separate csv.
I think it´d be more practical and quick.
Thanks.
Last edited by brax; 09/11/17 10:03.
|
|
|
Re: Asset list
[Re: AndrewAMD]
#477153
05/24/19 15:45
05/24/19 15:45
|
Joined: Oct 2018
Posts: 72
JamesHH
Junior Member
|
Junior Member
Joined: Oct 2018
Posts: 72
|
In that case, use a blank Asset list by default, define your assets entirely in your script with AssetAdd, then use loop(Assets). You can coordinate the assets in whichever way you please. I tried this approach: In the main() function, I loaded a file with an empty asset list using assetList and then called assetAdd with each of the assets. However, this only added the assets to the GUI, and Assets remains empty with NumAssetsListed == 0 (so of course loop(Assets) does not work). Could this be a bug in Zorro version 2.03 that I am using?
|
|
|
|