Gamestudio Links
Zorro Links
Newest Posts
What are you working on?
by 3run. 09/19/19 09:42
Any chance of PBR materials with A8?
by Quad. 09/18/19 18:00
Sierra Chart Plugin
by AndrewAMD. 09/18/19 14:03
3d model editor
by karmacomposer. 09/18/19 13:18
Can MED export to FBX?
by karmacomposer. 09/18/19 13:07
I cannot get the A8 game engine to show anything
by karmacomposer. 09/18/19 12:38
Script, Start Trading Immediately
by jcl. 09/18/19 08:38
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
12 registered members (Ayumi, 3run, AndrewAMD, Quad, saulius, 20BN, kvm, MatPed, 3 invisible), 613 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Dark_Light, oxygenjoe, web20tpo, tarekhazem, Juanjo
18290 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Asset list #467940
09/08/17 20:17
09/08/17 20:17
Joined: Aug 2017
Posts: 101
Spain
B
Brax Offline OP
Member
Brax  Offline OP
Member
B

Joined: Aug 2017
Posts: 101
Spain
┐Is there a way to define my portfolio assets in an array for using it in the asset loop? ┐Could i obtain the corresponding index for an asset in the array given its name?

Something like a HashTable or so, I know 'Assets' exists, but seems to be read only.

Thanks.

Re: Asset list [Re: Brax] #467941
09/08/17 21:10
09/08/17 21:10
Joined: Feb 2017
Posts: 754
Chicago
AndrewAMD Online
User
AndrewAMD  Online
User

Joined: Feb 2017
Posts: 754
Chicago
Like this?

Code:
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: 101
Spain
B
Brax Offline OP
Member
Brax  Offline OP
Member
B

Joined: Aug 2017
Posts: 101
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.

Code:
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: 754
Chicago
AndrewAMD Online
User
AndrewAMD  Online
User

Joined: Feb 2017
Posts: 754
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: 101
Spain
B
Brax Offline OP
Member
Brax  Offline OP
Member
B

Joined: Aug 2017
Posts: 101
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: Brax] #467966
09/11/17 10:48
09/11/17 10:48
Joined: Feb 2017
Posts: 754
Chicago
AndrewAMD Online
User
AndrewAMD  Online
User

Joined: Feb 2017
Posts: 754
Chicago
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.

Re: Asset list [Re: AndrewAMD] #467973
09/11/17 17:35
09/11/17 17:35
Joined: Aug 2017
Posts: 101
Spain
B
Brax Offline OP
Member
Brax  Offline OP
Member
B

Joined: Aug 2017
Posts: 101
Spain
Thank you very much! This is what i was looking for.

Now my code looks way more elegant! laugh

Re: Asset list [Re: Brax] #467974
09/11/17 18:43
09/11/17 18:43
Joined: Feb 2017
Posts: 754
Chicago
AndrewAMD Online
User
AndrewAMD  Online
User

Joined: Feb 2017
Posts: 754
Chicago
Yay! Actually, I might use this setup myself, especially for larger portfolio jobs.

Re: Asset list [Re: AndrewAMD] #477153
05/24/19 15:45
05/24/19 15:45
Joined: Oct 2018
Posts: 35
J
JamesHH Offline
Newbie
JamesHH  Offline
Newbie
J

Joined: Oct 2018
Posts: 35
Originally Posted By: AndrewAMD
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?


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1