Formula Entry
Common sets of controls are used to enter the formulas for function definitions and entry/exit system rules. They are divided into two major sections.
p Formula View Area
This area displays the formula in its current state. It is located at the top of the dialog. Directly beneath the formula view area is a prompting line with information about what is currently being selected in the view area.
p Entry Sub-Pages
This area contains sub-pages with options for what can be placed at the currently selected position in the view area.
Understanding the Formula View Area
The formula view area uses text highlighting to indicate the currently selected position in the formula, as well as additional information about different parts of the formula.
Inverse Text Current selection in the formula.
Bold Text Function containing the current selection.
Italicized Text Undefined portion of the formula.
Underlined Text Value provided by an input field.
As values are specified for each portion of the formula, the current selection will advance to the next position so that it can be defined. To jump to a specific position in the formula, simply click on the desired portion of the formula. The Formula View Area will automatically update with the correct highlighting.
As each new portion of the formula is selected, the prompt region will indicate what action will be taken by making a selection in the entry sub-pages. The formula entry sub-pages will also be updated to display what can be placed at the current position.
Entering a Formula
Formulas are entered into the formula view as a collection of functions, input fields, and numeric constants. They consist of a call to only one main function. However, the parameters to that main function can be calls to other functions.
In general, formulas are entered "from the outside, in." In other words, the outermost functions are entered first and the parameters to those functions are the innermost functions. Typically, this is the reverse of the order that these functions would be performed by hand.
: Example: A moving average is a summation of the n most recent values divided by n. As a formula, this would be entered as a division, which takes as its first parameter a summation.
Using the Formula Entry Sub-Pages
To specify a value for the currently selected position in the formula view, use the formula entry sub-pages. Different sub-pages are displayed depending on what is required at the current position in the formula. Most of the sub-pages have an insert button that allows you to insert things into the highlighted portion of the formula. This insert button will be labeled Insert into Formula if the highlighted selection has not yet been defined, or Change in Formula if the highlighted section contains a previous selection.
0 Function Definition
This sub-page is used to insert a function into the formula. To insert a function, select the function group from the Function Group list and select a function definition from that group, then press the insert button. You can also select a function definition by double-clicking on the function name.
If you would prefer to see more entries in the function definition list, you can add or remove the description area using the Display Descriptions checkbox.
0 Input Field
This sub-page is used to insert an input field into the formula. Input fields are parameters that are given values when the function definition is used, either in an input field or in another function definition.
To specify a new input field, press the Create New Input… button. This will display the Modify Input Dialog, which will allow you to specify the name and type of the new input.
To use an existing input field again, select the input field from the input field list and press the insert button. You can also select an existing input field by double-clicking on the input field name.
To change the name or type of an input field, use the Edit Selected Input… button to display the Modify Input Dialog.
To change the order of the input fields, use the Slide Up and Slide Down buttons or drag the input to a new position in the input list.
Ä Note: The order and number of the inputs cannot be changed when a function is being used by another definition. To modify the inputs of a function that is currently in use elsewhere, make a copy of the function and modify the copy.
0 Numeric Constant
This sub-page is used to insert a constant value into the formula. To insert a constant value, enter the value in the box and press the insert button.
0 Special Processing
This sub-page allows you to perform additional tasks at the currently select position.
· Add Level
This button allows you to add an Identity function around the current selection. This is useful for adding additional processing to a formula without having to enter the whole formula again. Once the Identity function is added, it can be changed to any other function definition.
· Remove Level
This button allows you to remove a function from the formula, replacing it with its first input as the current entry. This is the opposite of the Add Level button and is useful for removing unneeded processing.
þ Special Array Processing: Use Current Value…
This checkbox allows you to use the current value of the selected function for all values in the surrounding array function. It is typically used in a Summation function when comparing the current value of a function to a series of previous values.
To use the current value of an input field instead of a function, place the input field inside of the Identity function.
Ä Note: Array functions and functions that contain the "Previous Value of Function" function cannot be selected for returning their current value. To return the current value of these functions, use Add Level to add the Identity function around them, then select the current value of the identity function.
Ä Note: Array functions include: Summation, Median, Highest, Lowest, Was True, Bars Since Highest, Bars Since Lowest, and Bars Since Was True. They do not include functions that include these functions, such as Moving Average.
: For an example of the uses of the Add Level button and the Special Array Processing checkbox, see Example: Writing an Absolute Difference Summation.
Examples of Entering Formulas
: Example: Writing a Moving Average Function
: Example: Writing an Absolute Difference Summation
How Did I Get Here?
Formula Entry is done from both the Modify Function Definition Dialog: Formula page and the Modify Rule Dialog.