The RTL language supports user Text variables (T#) that can hold up to 30 characters of text. Each ticker symbol tracked by Investor/RT has its own set of 64 textual values, which are permanently retained in the Investor/RT database.
The RTL token names for these variables are T#1, T#2, ... T#64, analogous to the nomenclature for numeric V# variables. A title to each Text variable (that will show up, for example, when adding a T# variable column to a QuotePage) can be assigned through the same File > Preferences> User Variables menu.
Like V# variables, T# variables are per symbol. T#1 for symbol X can have TextA as content while T#1 for symbol Y can have TextB. If you add T#1 on a QuotePage, each line will reflect the specific text string associated with each instrument. Please note that T#1...T#32 are persistent (per symbol) on the database. T#33...T#64 are for temporary usage, they have no textual content each time Investor/RT starts up; once set, the value is retained until Investor/RT exits.
Part 1) Displaying the content of T# variables
QuotePage Column: Like V#'s, any T# variable is available in the list of built-in columns and may be displayed in a quotepage (or included in a quotepage format).
Annotation indicators: , let's consider for example, a chart annotation setup as "%TICKER at %CL %T#11". The annotation will normally display just the ticker and current price, but when T#11 is SET to "Buy Now", the annotation will update, showing that text in the chart window
More generally, any %T# expression can be directly added to text strings used as label or title option of multiple other I/RT indicators. This include the "Text" option of a Signal marker, The "Title" box of a Reference Line, Flexmeters(RTX) or Footprint(RTX), the custom label options for a ZigZag Indicator or PaintIndicator(RTX), etc
Part 2) Updating a T# variable through a SET statement inside an RTL formula
2.1) Generic SET statements
In any kind of scan, signals (or even Custom indicator formula), RTL supports the SET(target, source) statement where target and source are any of the 64 Text variables, or other RTL Tokens returning textual content.
- If the source token's text is empty, the target's text does not change.
- If the source text begins with + the text following the + is appended to the target's existing text.
- Otherwise, the source text replaces the target's former text.
- If the resultant text is too long, it will be truncated to 30 characters by the SET operation.
- The SET(target, CLEAR) statement will clear any text content (stored in a T# variable or other I/RT "text" tokens)
- The SET(target,UPPERCASE), SET(target,LOWERCASE) & SET(target,CAPITALIZE) will adjust accordingly the current string content.
2.2) Storing a constant textual String ("Hello")
SET(T#1,"Hello") does store the "Hello" string into T#1, whatever the previous textual string stored into T#1
SET(T#1,"+ World") will return "Hello World"
You can also compose text from one or more T# variables. If, for a particular ticker symbol, T#3 is "hello" and T#4 is "world", the following statement will set T#5 to "hello world". If the resultant text is too long, it will be truncated to 30 characters by the SET operation. SET(T#5, "%T#3 %T#4")
2.3) Storing a "dynamic" text message into a T# variable
Any message that can be formatted with RTL tokenized string becomes a "dynamic message"
SET(V#1, MA) AND SET(T#20, "Buy %TICKER Below %V#1")
The moving average MA is first calculated, then the string "Buy %TICKER Below %V#1" is composed into something like "Buy AAPL Below 29.50" and this resultant string is set into the T#1 variable for display elsewhere in quotepages or annotations.
2.4) Conditional SET statements
Setting the variable can be conditional of course:IF (BUYSIGNAL=TRUE) THEN (SET(T#11, "Buy Now!")) ELSE (SET(T#11, CLEAR));
Please note that the RTL conditional operator (expression ? a:b) can also be nested to perform SET statements on text variables. The statement herebelow will set the text variable T#22 to "a" when V#1 > 0, otherwise it will set T#22 to "b" or "c" based on the value of V#2.
SET(T#22, V#1 > 0 ? "a" : (V#2 > 0 ? "b" : "c"))
Part 3) Alternative methods to update T# variables
3.1) Direct manual input in a QuotePage T# column
When a T# column is present in a quotepage, the cells in that column may be edited manually or updated with copy/paste operations, just as V# numeric values for any ticker symbol are adjusted in a quote page.
To add, for example, the T#1 column to an existing quotepage, just right click on any existing column title, select the menu "Add Column" and scroll down the list until you find "T#1"
3.2) The Edit User Variable indicator
The Edit User Variable indicator is the most convenient manual solution for selecting a pre-defined message and storing it in a T# Variables with a simple mouse click
3.3) Through a Signal Action
Whenever a Signal Action is activated, one of the possible trigger actions is to store the content of the text message box (which may include %RTL tokens as in annotation) into a designated T# variable. Only the first 30 characters will be stored into the T# variable.
3.4) Import from a third party source
The "Data Import feature" of Investor/RT supports importing of textual content into any of the 64 T# variables. Simply setup a quotepage format that specifies the arrangement of the tab delimited data items in the incoming file and use the "Current Quotes/Other" import type to bring external ticker-specific textual data into one or more T# variables.
Part 4) Using T# variables directly into scan or signal formula
4.1) Character pattern matching rules (using the * or ? wildcard characters)
T# variables can be scanned using character pattern matching, just as any other textual data token (such as USERDATA, or NAME) . Lets compare the following formula
- The signal or scan T#5= "BUY" will only return true when T#5 content is exactly BUY
- The scan formula T#5 = "BUY*" will list all instruments whose T#5 value begins with the three letters BUY, as the asterisk matches any string of zero or more characters
- The scan formula T#5 = "*BUY*" will find instruments having BUY anywhere in their T#5 string, as the ? will match any signal character. For example,the pattern "?B??" will match a T# string having exactly 4 characters with the second character of the 4 being a B.
Please note that these rules apply also to any RTL Text token
4.2) Pattern matching rules in a Custom Column based on a T# variable
T# variables can be added directly to quotepage like any built-in column, or you can add a T# variable using a Custom Column if you wish to have more control over the color presentation of the text in quotepage cells. When a custom column references a built-in T# column, remember that the only "rule" type that you can use for text variables in the "Matches Text Pattern" rule. When you SET T# variables you can set a color code of some kind into the text that in turn is detected by the custom column and used to control the background/text color of the custom column cells. Here is a simple example. Consider a scan that runs periodically (the scan could run standalone, or the scan might be invoked by another custom column for that matter. Here is the scan formula:
IF (SET(V#1, MA) & CL > MA) THEN (SET(T#1, "CL above %V#1")) ELSE (SET(T#1, "CL below %V#1"))
The custom column for T#1 could have two rules, the first one is a "Matches Pattern" rule with pattern text set to *above*, i.e. any string containing the word above, with an associated color combination of white text on green background. The second rule would match for pattern *below* and when true the text will display in white text on red background.
5) Various specialized uses of T# variables (retainer for @n special ticker symbols, Trading Strategy Names or Live Trading Order IDs)
- @n special ticker symbols: please review the I/RT 11.3 release notes (second topic) for more information on this very specific use of T# variables
- Trading strategy name, as they do appear in Trading order setup presets, may be introduced as a T# variable, as discussed in this support page.
- Live Trading Order ID: it is recommended to use T# variables to store such information (that may have complex and long character strings) obtained from Trading Order ID Tokens. As this is already the case for strategy name, the Trading Order object is designed to also accept such T# variables (as orderID reference) in its setup window.
Related Articles:
- Using RTL "text" tokens in Scan formulas and updating their content with SET statements
- Identifying Symbol Groups in QuotePages using T# Variables.
- V# Variables (The numerical cousins of T# Variables)
- C# Variables ("Chart" Variables, which are not linked to a symbol but to a Chart)