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.