The symbols section should be used to request time series data for specific symbols (securities, indices etc.). This is useful if you need certain time series data in your study (for example a specific currency pair, advance / decline data or similar data) in addition to the symbol that is already present on the chart or in the price page.

Note             In TeleTrader WorkStation, all stocks, futures, options, indices and other securities are called symbols. A symbol is the unique identification given to every security that is traded on an exchange or over-the-counter market.

As you already know, you can access the time series of a symbol by using it as a base in your study (see Accessing the Time Series). A base is a special kind of input parameter of the type Security or Field (see Parameters). When inserting a study in a chart, the symbol / time series that is visible on the chart usually becomes the base for the study. You can of course manually change the base in the Insert Study dialog if necessary.

Yet there are some studies (for example Market Breadth indicators) that make use of additional data that might or might not be present on the chart (for example advance / decline data). You can of course write a study with several bases (parameters), and let the user choose the appropriate advance / decline symbols each time he inserts the study. However, in some cases it might be easier to just integrate these symbols once into the source code of the study itself.

As you cannot define a variable to hold time series data (variables can only hold numbers, text or Boolean values) , and you don’t want to use a parameter (as described above), you have to use the symbols section to map a time series to an internal identifier (symbol name). Once you have chosen a symbol name, you immediately assign the time series by using its symbol ID (for example {1947579}) or unique name (for example AT0000720008#CM_VIE). There are several methods to do this, which are explained in more detail below. You can then use the symbol in your program like you would use a parameter of the type Security. That means that you can for example access its individual elements (Open, High, Low, Close prices, Volume etc.), address past / future bars of the time series, use it as an input for drawing functions etc. The only difference between a symbol defined in this way and a Security parameter is that the symbol is hard-coded (and can therefore only be changed in the source code of a study), whereas a Security parameter is variable (and can be changed in the Bases section of the Insert Study dialog).

This section is optional. If used, it has to be positioned immediately after the parameters section.

Syntax

Symbols
   SymbolName = "SymbolID";

{ Using Case statements for symbol assignment }
   SymbolName =
Case EnumTypeParameter Of
                       ParameterValue1: "
SymbolID";
                       ParameterValue2: "
SymbolID";

                       ...
                
End;

{ Declaring more than one symbol at once }
   SymbolName1, SymbolName2 = "SymbolID", "SymbolID";

{ Mixing direct assignment and Case statements }
   SymbolName1, SymbolName2, SymbolName3, SymbolName4 =                          "
SymbolID",
                
Case EnumTypeParameter Of
                       ParameterValue1: "
SymbolID", "SymbolID";
                       ParameterValue2: "
SymbolID", "SymbolID";
                       ...
                
End,
                 "
SymbolID";

Symbols

Reserved word

SymbolName

Choose a name for the symbol (for example DowJones, EURUSD, Stock1 etc. – see Naming Conventions).

SymbolID

Internal identification of the time series (index, security etc.). You can either use the symbol identification number (for example {1947579}) or its unique name (for example AT0000720008#CM_VIE). The ID or unique name has to be enclosed in quotes.

To find out the identification of a symbol in TeleTrader WorkStation, click in the row of the symbol in a price page and press F2. Identification number and unique name can also be displayed in the price page columns TID and TUN.

EnumTypeParameter

Name of a parameter (of an enumeration type, see Enumerations) that controls which time series is assigned to the symbol (using a Case statement, see Case Conditions).

Use this method if you want to use one out of a group of (hard-coded) symbols in your study, depending on the controlling parameter. You can easily change the parameter value in the Insert Study dialog without having to change the source code of the study.

Further below you find an example using this method (including the necessary Enums and Parameter declarations).

ParameterValue1

ParameterValue2

Possible values of the controlling parameter. Depending on the parameter value that is chosen in the Insert Study dialog when using the study, the corresponding symbol will be assigned.

Example

In the following example, you can see the declaration of three symbols (src1 to src3). The first symbol is assigned a fixed value (the symbol ID {1947579}, which stands for the Google stock). The other two symbols are defined depending on the value of the exchg parameter, using a Case statement: If exchg is for example set to DAX in the Insert Study dialog, the two symbols will be set to the IDs {458757} and {458808}. In the NASDAQ case you can see how to use unique names instead of symbol IDs. The parameter exchg is defined with the enumeration type Exchange, which is defined in the Enum section.

This sample study draws the Close prices of the chosen symbols on the chart. Note that the usage of Symbols (src1 to src3) is comparable to that of a parameters of the type Security (Source).

Function SymbolExample
Returns Nothing;

Enum
Exchange = (ATX, DAX, NASDAQ);

Parameters
   Security Source;
   Exchange exchg;

Symbols
   src1 = "{1947579}";
   src2, src3 = Case exchg Of
                       ATX: "{399915}", "{399895}";
                       DAX: "{458757}", "{458808}";
                       NASDAQ: "MSFT_0FSPC", "AAPL_0FSPC";
                        End;  
  
Begin

   DrawLine("Variable_Security_From_Parameters", Source.Close);
   DrawLine("First_Symbol_Is_Fixed", src1.Close);
   DrawLine("Second_Symbol_Depends_On_Exchange", src2.Close);
   DrawLine("Third_Symbol_Depends_On_Exchange", src3.Close);
End.