How dynamically storing strings

For storing strings(symbols) dynamically in AFL which among these are best 1. Arrays 2.List 3.Matrix
and how to declare or initialize as empty?

@Kum001 Arrays an Matrices in AmiBroker stores only numeric values.

Using plain AFL, at present, there is no way to create your own (dynamic) lists (that handle any kind of object like in other programming languages), though some object-oriented code is employed when you need to use the CBT - Custom BackTest. See more info about this topic here.

You should look at StaticVarSetText() and StaticVarGetText().

There are plenty of examples in this forum (use the search clicking on the magnifying glass symbol at the upper right),
If you are a registered user you can also access a 3rd party plugin named Osaka that handles strings arrays/tables.

1 Like

The easiest method to keep symbol list is just comma separated string:


// get n-th element
nth_symbol = StrExtract( list, nth );

// iterating thru list
for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
  printf( "Item %g = %s\n", i, sym );

Such single variable (list) can be stored in dynamic variables (VarSetText/VarGetText) or in static variables and treated as entity without using any plugins or any other complicated stuff.