Not sure whether this bit was previously answered. I intend not to deal with external CSVs in order to extract symbols (reason being its slow speed). Objective is to plot charts and not to explore or scan. Let me use an analogy to better explain my situation:
The Option symbols in my AB Database are stored as in the format of <Name()>_<ExpiryDate>_<Strike><C or P>. For e.g. AAPL's 225 Strike for 10/26/18 expiry Call Option would look like AAPL_26OCT18_225C and for Put Option AAPL_26OCT18_225P.
Currently, the selected symbol is AAPL on Daily timeframe. I have an array that contains the ATM strike level for each EOD bar. Now whatever levels within +/-2 Stand. Dev. above and below the ATM Strikes are the different Strike levels to consider. I am also feeding my AFL with relevant Expiry dates. So, dynamically for each bar I am required to form the list of the Option symbols wherein even the Symbols are ought to formed by String manipulations.
What would be the fastest technique to form:
a) the dynamic lists of these string manipulated symbols for every visible candle;
b) loop through the changing list of symbols for every bar in order to pull out their OHLC Vol/OI arrays using Foreign function?
StrExtract() is one of the fastest implementations of its kind.
tickers = "AAPL,MSFT,INTC";
// Iterate End to First
for( item = -1; ( sym = StrExtract( tickers, item ) ) != ""; item-- )
{
printf( sym + "n" );
}
// Snippet from Guide.
The problem is if you call each +/-2SD for each bar, you will be repeating symbols, so why don't you create a list of symbols that are required and then call each Foreign() Symbol only once?
I know i've just scratched the surface, but its a start. The string computation is definitely one of the fastest ways that I've read on the forum about.
For me the challenge is that I am unable to work on fixed set of symbols. I wonder whether it would be possible to have a dynamic SymbolList for every visible bar?
With Amibroker it ought to be way simpler than you think.
I assume, although you do not have the list or symbols ready beforehand but you know the number of symbols you want to interact per execution. That's all you need actually. I used to have similar logical issues when I started using AB after migrating from another charting platform.
Consider the loop below:
SymNum = 10; //Number of option symbols to be looked for
for( i = 0; i < SymNum; i++ )
{
VarSet( "OptC" + i, Foreign( "Your Symbol Format", "C", False ) );
}
Once you have defined the Variables, now you can call them accordingly for further calculations.
But this type of code should be part of a "Run Once" code structure otherwise you will end up running the loop for multiple times without even realizing it.