create string array?

Posted By: Grat

create string array? - 05/06/21 06:46

Hi,

how to create the string or char array?

string aSymbol[12]={"EUR/USD","USD/JPY","EUR/JPY","AUD/USD","NZD/USD","AUD/NZD","USD/CAD","GBP/USD","EUR/GBP","GBP/JPY","AUD/JPY","EUR/CAD"};

have


omegaData compiling............
Error in 'line 15:
syntax error
< string aSymbol[12]={"EUR/USD","USD/JPY","EUR/JPY","AUD/USD","NZD/USD","AUD/NZD","USD/CAD","GBP/USD","EUR/GBP","GBP/JPY","AUD/JPY","EUR/CAD"};
>.
Posted By: AndrewAMD

Re: create string array? - 05/06/21 13:40

First, you declare the array, no initialization.

Then, from 0 thru 11, you assign a string to each.

Like:
string aSymbol[12];
aSymbol[0]="EUR/USD"; // and so on
Posted By: Aku_Aku

Re: create string array? - 05/06/21 15:58

Variation 1
Code
STRING* asymbol[12];
str_cpy(asymbol[0], "EUR/USD";
str_cpy(asymbol[1], "USD/JPY";
str_cpy(asymbol[2], "AUD/USD";
... and so on...

Variation 2
Code
TEXT* asymbol = {
     strings =  ("EUR/USD","USD/JPY","EUR/JPY","AUD/USD","NZD/USD","AUD/NZD","USD/CAD","GBP/USD","EUR/GBP","GBP/JPY","AUD/JPY","EUR/CAD");
}

I'm not sure the syntax is totally OK, I wrote it without any editor, help or so.
Posted By: Grat

Re: create string array? - 05/06/21 16:34

my solution:
Code
#define SYMBOLS "EUR/USD","USD/JPY","EUR/JPY","AUD/USD","NZD/USD","AUD/NZD","USD/CAD","GBP/USD","EUR/GBP","GBP/JPY","AUD/JPY","EUR/CAD"
string aSymbol[12];
...
...
if (is(FIRSTINITRUN)){
   while(asset(loop(SYMBOLS))){
         aSymbol[i]=Asset;
   }
}
Posted By: Aku_Aku

Re: create string array? - 05/07/21 07:24

If it works, something really new must be implemented in GS.
Or is it a Zorro feature?
Posted By: jcl

Re: create string array? - 05/10/21 10:11

Variants 1 and 2 are wrong. The variant by Grat is correct syntax, but the loop function is normally for portfolio optimization, not for array filling. Andrew's version is correct.
Posted By: Aku_Aku

Re: create string array? - 05/10/21 15:07

Yeah, Zorro is different.
© 2024 lite-C Forums