The parameters section is used to define input values that will be needed throughout the program. These values have to be passed to the program before it is executed, which also means that you can change these values every time you use your program. The more parameters a program has, the more flexible it is, because it is able to work with different input data.
For studies, parameters are normally passed to the program on the Parameters tab of the Insert Study dialog in TeleTrader WorkStation. You can change the values for each parameter there and so make the program work with different input data. This makes it possible that one study, as for example the Moving Average, can be calculated for any security and with any given period. If a program would not use parameters, you could for example not apply it to another time series (security).
For other programs, you have to pass the parameters manually when you call the program. For example, if you use the built-in function Sum, you have to provide two values for its two parameters – what items should be summed up, and how many of these items should be summed up. Therefore, you call the program e.g. with Sum(source, period).
There are three basic types of parameters: Value, Field and Security.
▫ Value parameters show up in the Parameter section on the Parameters tab and are used for single values, such as the period parameter of the Moving Average.
▫ Field parameters show up in the Bases section on the Parameters tab and are used for specific elements of a security, for example the Open or Close price. You can choose the base element that is used in the study in the Insert Study dialog, and you can then only use this element (e.g. Close price) in your program.
▫ Security parameters also show up in the Bases section on the Parameters tab. In contrast to the Field parameters, they contain all elements of a security. In your program, you can choose which elements you use for a calculation by writing for example source.Close or source.Open.
The Value and Field parameters must have an additional parameter type that defines what kind of value the parameter holds. This additional type can be Numeric, Text or Boolean.
Note For your custom studies, you will in most cases need at least one parameter source that defines the base for your study. This parameter can be of the type Security or of the type Field. All parameters of this type will show up in the Bases section of the Parameters tab.
This section is mandatory.
Reserved word. You can also use Params instead.
Possible parameter types are:
For Value parameters:
Numeric Input value is a number
Text Input value is text
Boolean Input value is the logical value True or False
For Field parameters:
Numeric Field Input is a security (base) field with a number value
Text Field Input is a security (base) field with a text value
Boolean Field Input is a security (base) field with a logical value
For Security parameters:
Security Input is a security (base) with all its properties
You can also define custom types by using enumerations: See Enumerations.
Choose a name for your parameter (see Naming Conventions)
Define two parameters for the Moving Average: The price of the underlying security and the period of bars for which the average should be calculated.
Numeric Field source;