Tips - Setting V# Variables

Today's tip will cover the use of V# variables in QuotePages, Scans, Custom Indicators, and Trading Signals. Additional Information on Setting V# Variables can also be found in the Scan Tutorial.

You can think of the V# variables as 512 distinct fixed properties of an instrument, i.e. each instrument has its own set of 512 V# variables V#1 through V#512. All V# variables are persistent across executions of Investor/RT, that is, their values are retained permanently on the database so they are "remembered" the next time I/RT starts up. V# variables contain the last value SET into the V# by a scan, custom indicator, or trading signal (within a backtest run). Unlike other properties of instruments that are updated by the arrival of data from the data source, V# variables are updated only when a scan, trading signal, or custom indicator is evaluated.

A scan can be run once, or run periodically (using autoscan), or scans can be invoked for a particular instrument by embedding the scan as a scan/signal marker within a chart. If the chart is updated in real-time, any SET(V#... statements within the scan are evaluated tick by tick.

Custom Indicators can be invoked by any scan or trading signal (within a backtest run), or custom indicators may be calculated by embedding the custom indicator within a chart. If the chart is updated tick by tick so will the V# variables in the custom indicator that are the subject of a SET statement. When a custom indicator is embedded within a scan, the running of the scan controls when SET(V# statements within the custom indicator are triggered.

Finally, Trading Signals are calculated when a backtest is performed, or when the trading signal is embedded within a chart (scan/signal marker). If the chart is updated in real-time, any SET(V#... statements within the scan are evaluated tick by tick. SET(V# statements are useful for setting stops with a trading system. Any SET(V# statements within a trading signal will be executed (many times) during a backtest run.

SET(V#n, expression) can be done within any of these contexts. What you see in the quote page column V#n is the most recently calculated result of the V#n variable.