Introduction to The Indicator Builder
We believe that understanding The Indicator Builder is essential to using MetaStock. This component allows us to create our very own customised indicators. In this way, we can recreate indicators we may have seen in other charting applications, read about in books or seen in magazines.
What’s more, once an indicator has been created, it’s accessed in the same manner, and has the same characteristics, as all the other pre-packaged MetaStock indicators. Not only can these indicators assist in our visual assessments of charts, but they can also form the basis of explorations, expert advisors and system tests alike.
Creating a New Indicator
The best way to learn about The Indicator Builder is by way of example. Therefore, we’ll create an indicator describing the steps and menus along the way.
To begin, open The Indicator Builder by either clicking the ‘Indicator Builder’ on the Standard Toolbar or by selecting it from the ‘Tools’ drop down menu. This opens the dialog box shown below:
From within this dialog, indicators can be created, edited, copied, deleted, and printed. The options available in this dialog box are as follows:
- Close: Closes the Indicator Builder dialog.
- New: Displays the ‘Indicator Editor’ dialog, which is used to create our custom indicator.
- Edit: Displays the ‘Indicator Editor’ dialog of the selected Indicator. This is used to alter an existing indicator.
- Copy: Makes a copy of the selected indicator, allowing us to rename it and change the original indicator.
- Delete: Deletes the selected indicator.
- Print: Prints the details of the selected indicator(s) including all the name(s) and their respective formulas
- Organizer: Displays the ‘Formula Organizer Wizard’. It enables us to import and export formulas from any of the four formula tools within MetaStock.
- Help: Displays the help page on Indicator Builder dialog.
Let’s create a new indicator that identifies securities that have reached a new high, specified by the user. Click ‘New’, and you should see the ‘Indicator Editor’ dialog, shown below:
The cursor will be in the ‘Name’ text box which is obviously where we name our custom indicator. To the right, there is a check box denoting whether or not we want our new custom indicator to be listed in MetaStock’s ‘QuickList’. As a general rule, we would want this box ticked. There is also a ‘Functions’ button available in the Indicator Editor. This allows us to paste the correct syntax of any function straight into any formula, which is a very handy feature. To the left of this, there is the ‘Formula’ text box which is where the actual coding for the indicator is placed.
We have chosen to name our custom indicator the ‘My First MetaStock Indicator’. Next enter in the following formula into the ‘Formula’ text box:
periods := Input(“Enter the number of periods for the highest high”, 1, 9999, 120) ;
In our example we have used both the variable and input functions. The variable function allows us to assign a word to a particular expression, which can then be used in the formula. We have coupled this with the Input function, which will prompt the user to enter a value.
Let’s examine our formula further. ‘periods’ is the word that is assigned to the expression. “Enter the number of periods for the highest high” is the text that will prompt the user to enter the value for ‘periods’. The three remaining values within the formula set the parameters for the value of ‘periods’. In our example, ‘1’ is the minimum value accepted; ‘9999’ is the maximum and ‘120’ is the default selection.
The effect is such that, once the indicator is applied to a chart, the user (aka you) is prompted to enter a value. This value is then used within a formula. We haven’t entered this formula yet, so after the code we’ve already entered, type the following:
C>Ref(HHV(C, periods ),-1)
The second part of our formula identifies the previous period’s highest high value, achieved using the Reference function. Subsequently it then checks whether the current period’s closing price is greater than this value (denoted by ‘C>’). If this condition exists, then the security has achieved a new high for the last ‘x’ number of periods. The whole formula should now read:
periods := Input(“Enter the number of periods for the highest high”, 1, 9999, 120) ;C>Ref(HHV(C,periods),-1)
as shown below:
Note that the semi-colon between the two expressions stipulates to MetaStock that they are separate. In other words, MetaStock first calculates the input function and then calculates the ‘Highest High Value’ function.
We’ve now created our first indicator, let’s try it out. Click ‘OK’ to get back to the ‘Indicator Builder’ dialog and then ‘OK’ once more. Open a chart and we can now apply our new indicator by using the indicator drop down menu, or QuickList. When applied a dialog box immediately appears, prompting us to set the value for ‘days’, shown below:
Once the value has been inputted, MetaStock will calculate the formula and apply the results to the chart.