The enumerations section can be used to define your own parameter or variable types, in addition to the built-in types (Numeric, Text, Boolean etc.). After defining a new enumeration type, you can use it immediately to declare parameters or variables of this type in the same program. In contrast to the built-in types, an enumeration type always comes with a specific set of named values. Only these values can later be assigned to a parameter or variable of this type.

You could for example create an enumeration type called Color with the values Red, Green and Blue. If you now declare a variable MyColor of this type, you can only use the defined values (that means, if you assign for example the color Yellow to your variable, this will create a syntax error). If you declare a parameter of the type Color, the three possible color values will be available as a list in the Parameter section of the Parameters tab.

Enumerations are therefore especially useful if you want to make sure that only a few pre-defined values can be assigned to a parameter or variable. This also makes them very helpful when using Case statements (see Case Conditions).

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


EnumName1 = (EnumValue, EnumValue, ...);
EnumName2 = (EnumValue, EnumValue, ...);


Reserved word. You can also use Enum instead


Choose a name for the enumeration type (for example Mode, Color etc. see Naming Conventions).


Define the possible values (enumerators) for this enumeration type. Only these values can be used for parameters or variables of this type.


By using enumerators, you can make it more intuitive for the users of a study to choose relevant values for certain parameters. In the following example, you can see an enumeration type called Mode that is used for declaring the parameter multiply. In the Insert Study dialog, the user will be able to assign the value Normal, Twice or Half to this parameter. Depending on what he chooses, the example indicator will show the double or half Close prices of the base security as a line.

Function EnumerationExample
Returns Nothing;

Mode = (Normal, Twice, Half);

Security Source;
Mode multiply;

Numeric price;


If (multiply = Twice) Then
price = Source * 2
Else If (multiply = Half) Then
price = Source / 2
price = Source;

DrawLine("SampleLine", price);