I've enjoyed Amibroker's regular innovations. Sometimes however, I become confused about what performance enhancements supercede others. For me, this seems inevitable given Amibroker's stellar continuous quality improvement and my inability to absorb all the many improvements required to stay absolutely current. I would welcome some clarification.
My understanding is that Amibroker native price arrays are the gold standard in efficiency and memory management. Towards maintaining that efficiency, I've been using this approach:
My use case:
I mostly trade options. I use Amibroker to backtest potential option spreads. Up to this point I have been analyzing the potential market setups and possible option combinations in other software platforms (MATLAB and C++) and then importing the resulting data into Amibroker for backtesting confirmation. I would like to now move the initial potential setup and combination analysis into Amibroker and simplify my data management. I know that Amibroker has the power to do everything I require so long as this backyard programmer can harness it!
Currently, I am using ASCII import to retrieve the option data from a vendor supplied end-of-day option chain. For each option I import: Symbol, Date, O, H, L, C, V, OI, AUX1(bid), AUX2(ask).
I then import the preprocessed results from my trade analysis/setup into three synthetic tickers (using all six available price variables in each synthetic ticker): Name() + _extra; Name() + _IVcoefficients; and, Name() + _greeks.
Each backtest has a specific start bar and a specific end bar for analysis. I compute a spread price at each bar. I am currently using SetForeign() to assign option leg prices to variables and then summing the prices of the legs for the option spread price, greeks, etc. I am not doing any charting.
I have read various posts in this forum about static variables, synthetic tickers, as well as the guide for SetForeign(), StaticVarSet(), StaticVarGet(), etc.
My confusion revolves around the comparative efficiency (memory usage and speed) of three differing approaches to accessing/manipulating data: Amibroker native price arrays, static variables, and the various uses of SetForeign() and Foreign() and also AddToComposite.
For example, this document indicates that a single SetForeign() that allows access to the native price array data in one call is 6x faster than the equivalent number of individual Foreign() calls, taking about the same time as a single Foreign().
And, here, it is stated that using read once/save once, static variables offer the same speed as regular variables (no speed penalty).
Are static variables used in this way always as efficient as a variable created by adding price data from several instances of SetForeign() (such in my case above)?
From what I have read and understand, if I am evaluating data in a bar by bar manner, then native price arrays are to be preferred. However, I don't want to make any assumptions so I am asking for clarification. Is using native price arrays in this way more efficient than static variables or any other approach within Amibroker? When would I prefer static variables to variables holding native price array data if the computations can be achieved using either?
Any explanations or references would be enthusiastically appreciated!