images/contents.gifimages/index.gifimages/prev1.gifimages/next1.gif

Formula Names and Declared Parameters

A formula name consists of a unique name and a parenthetical statement containing the parameters you want to declare for the formula, i.e.,

images/aspen00000186.gif

A formula name must be unique. If a formula name duplicates a reserved word (dot commands), the formula evaluator will reject the name.

If the formula you are writing is a simple algebraic statement, the formula name does not require the parenthetical statement that contains declared parameters. For example, if you want to add an instruments high to its low and divide by two to identify the mid-point of a range, your formula does not require any declared parameters. However, if you use one or more study functions in a formula, the study name does require declared parameters.

Not only do declared parameters govern how the formula gets calculated, they also serve as the basis for a formula studys parameters menu. A parameters menu enables you to change the settings controlling the formula studys output. For example, in the following formula, the expression contains a function (which you will read more about later) that calculates a slow stochastic. The formula looks like this:

images/aspen00000187.gif

The formula name declares four parameters: SERIES, PERIOD=14, SMTH=.25, and SMTHR=.15. This formula creates a parameters menu that looks like this:

images/aspen00000188.gif

This parameters menu contains a field for every parameter declared in the formula. Notice that in the parameter declaration, we set PERIOD equal to 14. As a result, 14 serves as the default number of periods in the formula. The same is true for other parameters we set in the declarations. Were we to omit default values in the declarations, the parameters menu would use zero (0) for all values, and the formula would not produce a line until we displayed the parameters menu and provided values. Lets take a closer look at whats going on here.

The formula name,

SSTOCHSTEST(SERIES,period=14,smth-.25,smthr=.15)

declares four parameters, SERIES, period, smth, and smthr. Further, in three of these parameters, we have assigned a default value: period has a default value of 14 (fourteen periods), smth has a default value of .25, and smthr has a default value of .15. When you declare parameters, the program creates a parameters menu for the study. With the exception of the Type parameter (SERIES or INPUT), all parameters declared in the formula name become fields in the formula studys parameters menu. If you supply default values for a parameter, the default values appear in the parameters menu as well. In the following figure, you can see how the parameters and default values become a part of the formula studys parameters menu:

images/aspen00000189.gif

Notice that the parameters menu contains parameters that were not declared in the formula name. While the parameters menu contains the parameters declared in the formula name, it also contains three parameters that were not declared: price, color, and graph. These parameters are standardthat is, you get them whether you declare them or not.