By "Text" Token, we mean tokens (or elements) in RTL that return textual strings. This webpage reviews the list of Text tokens, ie RTL Tokens returning a textual string, the way to use them in Scan formulas and how to update their content.
Make sure you are familiar with Text Variables (T#) before reviewing this page.
Part 1) List of RTL tokens returning textual strings
Other than Text Variables (T#), these tokens include:
| Token | Description |
|---|---|
| ALIAS | DTN Ticker Symbol (for the DTNMA Historical Data Downloading service) |
| BALIAS | Brokerage Alias Ticker Symbol |
| CURRENCY | Currency (Any type of instrument) |
| CUSTOM | Custom String - Any user-defined character data (can be added as a column to quotepages) |
| EXCHR | Requested Exchange |
| EXCHT | Exchange of Trade |
| INDUST | Industry (Stock instruments) |
| MSG | Last line of the Message Log (%MSG to be used in the chart "Annotation" indicator) |
| NAME | Security Name |
| PFO | Portfolio (Scan formula PFO = "Tech1"; Find instruments held in portfolio Tech1) |
| QP | QuotePage (Signal QP = "myStocks" is true if the issue is listed in the "myStocks" quotepage) |
| SECTOR | Sector (Stock instruments) |
| SESNAME | Chart Session name (%SESNAME to be used in the chart "Annotation" indicator) |
| TICKER | Ticker Symbol |
| USERDATA | Custom text token (prior to the creation of T# variables) - can be added to Quotepage |
| RTL Tokens designed to manipulate textual string properties (of any T# variables or Text Tokens) | |
|---|---|
| CLEAR | SET(T1#,CLEAR) |
| CAPITALISE | SET(T1#,CAPITALISE) |
| LOWERCASE | SET(T1#,LOWERCASE) |
| UPPERCASE | SET(T1#,UPPERCASE) |
Part 2) Using textual string Tokens in Scan Formula
In order to use these tokens in a RTL expression, you must compare them to other strings. You may also make use of the wildcard characters(*, ?) within your string. Some examples follow:
Example 1: Security Name
If, for instance, you were a CQG user and you wanted to delete all the symbols in your system which are Invalid CQG Continuum symbols. Since CQG returns a name of "*** Invalid CQG Continuum Symbol ***" for all symbols which it does not recognize, you could perform a scan on your ".All Symbols" quotepage which looked for Security names of *** Invalid CQG Continuum Symbol ***. The syntax for your scan expression would look like this:
NAME = "*** Invalid CQG Continuum Symbol ***"
Note that you must enclose the *** Invalid CQG Continuum Symbol *** in quotes. This scan would return a quotepage filled with all your Invalid myTrack symbols, and you could simply delete them all from your system.
Example 2: QuotePage - Finding overlapping symbols
If you had two quotepages and you wanted to find all the symbols which existed in both quotepages, you would do the following. Let's say the names of the quotepages are "hisQP" and "herQP". You would perform a scan on the "hisQP" quotepage and use the following expression.
QP = "herQP" The results of the scan will be a quotepage which contains all the symbols which the quotepages "hisQP" and "herQP" have in common.
Review this support page for another example:
Example 3: Ticker Symbol - using Wildcard Characters (* and ?)
If you had a large quotepage called "myOptions" and you wanted to filter out all the AOL options ticker from that quotepage, you could do the following. You know that all the AOL options begin with the three letters "AOO". You can make use of the wildcard character, "*" to find all the symbols in the quotepage which start with "AOO". So you would run a scan on the quotepage "myOptions" using the following expression:
TICKER = "AOO*" There are two wiildcard characters. "*" represents any series of 0 or more characters, and "?" represents any single character. Therefore, "*EST??" would search for any text that ended in EST followed by any two characters, regardless of how it begins. So the words "FORESTER" or "BESTED" would match this criteria, but "BEST" would not.
Part 3) Using SET statements to manage Text Tokens
RTL token corresponding to Text Variables (T#1 to T#64) or Tokens capable of storing text (see list above) can have their content adjusted through SET statements.
Indeed, RTL supports SET(target, source) where target and source are any of the text tokens in the language.
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.
Here are some Signal and Scan SET formula examples
Example 1: SET(T#1, SECTOR); SET(T#2, T#1);
The content of the T#1 variable is copied into T#2
Example 2: IF (CL > STAT) THEN SET(USERDATA, "+ New High %DATE");
This scan formula uses the + to append some text to the USERDATA token conditionally. The STAT token is setup to find the highest high for some period of interest. When the scan runs and finds an instrument closing above its long term high, the text " New High mm/dd/yyyy" is appended to the user data. The %DATE token in the quoted string is replaced by the current date.
Example 3: SET(T#3, (USERDATA= "*BUY*") ? "+***" : "+???");
T#3 will have "***" appended to its text for all instruments having the letters "BUY" anywhere in the user data text. Instruments without the BUY text will have "???" appended the T#3.
Example 4: IF (CURRENCY != "?*") THEN SET(CURRENCY, "USD") ELSE SET(CURRENCY, UPPERCASE);
If the CURRENCY field for the instrument is empty (i.e. it does not match the pattern above), then set the currency to "USD" (US Dollars), otherwise uppercase all characters in the currency code field of the instrument.
Final Remark: There are four special token names you can assign to any text variable to manipulate the text of the variable: CLEAR, UPPERCASE, LOWERCASE, and CAPITALIZE. Examples are shown below:
SET(USERDATA, CLEAR);
SET(SECTOR, UPPERCASE);
SET(T#30, LOWERCASE);
SET(INDUSTRY, CAPITALIZE);