The indicator token AV in the RTL language enables time-stamped historical values to be saved in the Investor/RT database for any ticker symbol. Just as User V# variables provide a means of saving a single computed value for a ticker symbol, the AV token can be used to save a historical array of values, one value for each bar backtested. The AV token is a historical token, thus it has values for each bar; previous bar values can be referenced in an RTL formula with a bar qualifier (AV.1, AV.2, etc.). A value can be set for a bar using the SET function, e.g. SET(AV,
The AV token, like other "indicator" tokens, has a setup window. A "Persistent..." checkbox, when checked, means that the historical values SET into the array by a signal will be saved in the Investor/RT database. If the "Persistent" checkbox is unchecked, this means that the array is a "temporary" array. A temporary historical array is initialized to zeros. Values may be SET into the array during a backtest; present and past values of the array may be referenced by the signal during the backtest; the array values are discarded upon completion of the backtest.
If the setup for the AV token specifies persistence, the historical data is loaded from and stored to the database using a "pseudo instrument" to hold the data. The pseudo instrument is created automatically by Investor/RT with a ticker symbol derived from the underlying ticker symbol. For example, if you run a backtest on the symbol MSFT and there is a rule in the trading system with a signal formula SET(AV, POS_SIZE), this will create an historical array of data matching the periodicity of the backtest with one AV value for each bar examined during the backtest. The setup for the AV token contains a "suffix" text option that is used to create the pseudo instrument. In this example, the historical values of position size are saved under a ticker symbol MSFT_A1, where A1 is the user specified suffix in the AV setup. The historical values of MSFT_A1 can be inspected using the View/Edit window. In this example you could add a signal marker to a MSFT chart having the formula AV.1 = 0 AND AV > 0; setting up AV with the A1 suffix. This would show signal markers on each bar where the backtest entered into a new long position. Persistent arrays can also be viewed in a chart directly using the "Array User Variable" indicator", just add the indicator to a chart like any other indicator. If persistent array data exists for the associated underlying ticker in the chart, it will be displayed in the chart as a line or histogram, etc. in accordance with the preferences for the Array User Variable indicator.
Another use of this facility is to perform a complex calculation using a one rule trading system, saving the results for each bar in an AV historical array. Then, when you optimize your actual trading system, the system's rules can refer to the AV values instead of computing the complex formula repetitively for all iterations of the trading system optimizer. This technique can be used to considerably reduce the time it takes to optimize trading systems having computationally intensive signals.
When an RTL formula that references a persistent AV token is executed (via a scan, signal, or custom indicator) Investor/RT will load previously saved AV values from the database. If there is no previously saved data, the AV token will be initialized to zero values for each bar. When the scan or backtest using the formula completes, Investor/RT will check to see if the array has been modified (via a SET statement) and if so, the updated array of value will be stored in the database. Investor/RT creates ticker symbols automatically using the suffix in the AV setup to serve as containers for the historical data. These pseudo ticker symbols have a security type of Cash. If you delete any of these tickers from your Investor/RT system, this is equivalent to setting the AV array values to zero for the underlying ticker symbol. You can open the ".Cash" system quotepage to see at list of all cash ticker symbols at any time. If you use common suffixes such as A1, A2, A3 etc for array storage, you can easily list all of the cash ticker symbols having a particular suffix by running a scan, e.g.
SECTYPE = SEC_CASH AND TICKER = "*_A1"
This will list all pseudo tickers ending with _A1, so you can view/edit the values or delete the entire list if needed.
Since the user specified suffix is any arbitary string of up to seven characters, there is no practical limit on the number of ARRAY user variables that can be created for an instrument. Caution is advised if you plan to use this feature with a large number of underlying ticker symbols since each unique suffix will result in the creation of a new pseudo instrument. You can keep an eye on the number of instruments created for array variables by opening the ".Cash" system quote page.