Авторы: 159 А Б В Г Д Е З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Э Ю Я

Книги:  184 А Б В Г Д Е З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Э Ю Я

All About Power Tools

MetaStock has several advanced features, based on the MetaStock formula language, collectively

referred to as power tools. These features allow you to customize your technical analysis. They

are accessed through the Tools menu and include the Expert Advisor, Indicator Builder, System

Tester, and The Explorer.

The power tools are extremely powerful tools that greatly enhance the capabilities of MetaStock.

They come with several predefined examples, but to really get the most out of them, you need to

be able to write your own. That’s where this text comes in.

The MetaStock formula language is not a massive collection of symbols you have to remember.

Instead, it is a small group of mathematical functions that the MetaStock program uses to

calculate a numerical value. We will create many formulas throughout this text. Each one will

show, by example, a new function or concept.

To do this, we will use the Indicator builder. This power tool is the easiest to use and is the basis

on which the other three are built. In case you’ve never looked at it before: in MetaStock, click

on Tools | Indicator Builder.

The window in front of you contains a listing of all the existing custom indicators in your copy

of MetaStock. The standard indicators are preset and you cannot alter them. A custom indicator

is a user-defined formula that can be plotted on a chart. When one of these custom indicators is

plotted, MetaStock calculates the value of the formula for every point of data in the chart and

draws a line connecting the values. Your first custom indicators will be very simple and

progress from there.

The custom indicators you currently have listed will not affect your ability to use this text. The

only possible problem that might occur is if this text suggests a name for an indicator and you

already have one by that name. When you try to create a formula with a name that has already

been used, you will get a message like the following:

If you receive this message, just click OK and type in a different name. It doesn’t matter what

name you choose. What you name it will in no way affect the formula or the calculation of the

indicator. However, when naming an indicator, you may find it useful for future reference to

have the name reflect the indicator’s formula or its intended function.

What’s in a Formula

Now that you know where custom indicators are created, it’s time to discuss the actual formulas.

A MetaStock formula is a logical arrangement of one or more functions, operators, and data

arrays. Don’t be intimidated by these terms. They are actually very simple concepts.

A function is a command to perform a specific mathematical calculation. Cosine and moving

averages are examples of functions. Others are more complex but they all take one or more

values and perform a set calculation.

Operators are basically a subset of functions that can be expressed by a single symbol. They are

separate because of a few operations that don’t have matching functions. For example, Addition

is a standard function but it is usually written with the single + symbol instead of the longer

function command.

Data array is simply a fancy term for an ordered grouping of numbers. The closing prices of

IBM are a data array. The volume of the NYSE is another data array. Each of these examples is

arranged in chronological order by dates in a MetaStock data file. Any such series of numbers

can be a Data array.

Now that the terms are defined, examine the formula definition again. A formula is a logical

arrangement of one or more functions, operators, and data arrays. Restated, this means the data

arrays, operators, and functions express a mathematical calculation for MetaStock to plot on a


Your first Indicator

An indicator can be written using just a data array, for example the closing prices. Formula 1

demonstrates this. Create an indicator with the formula below and name it Closing Prices.

Formula 1:


Copyright © 2002 Equis International

If you have never created an indicator before, just follow these steps.

1) Choose Indicator Builder from the Tools menu.

2) Click the New button.

3) Type the name of the indicator, in this case: Closing Prices.

4) Click in the large white box titled Formula

5) Type the formula: close.

Your screen should now look like the picture below:

6) Click the OK button.

7) If you get an error, check the spelling in the formula and make any corrections needed.

8) Close the Indicator Builder by clicking the Close button.

Congratulations, you have just written your first indicator. It will be listed in the Indicator

Quicklist after the built-in indicators. This is the place where all the custom indicators are

alphabetized. Now plot it on a chart and see what happens. You should get a line that exactly

matches the closing prices of the stock you plotted it on.

This indicator is no big deal because you could get the same thing by changing the price style to

a line chart. However, you have created an indicator. The volume displayed at the bottom of

most charts is an indicator with the following formula:

Formula 2:


If you wish, create the above formula and plot in a chart with the volume indicator. The only

difference is the volume is displayed as a histogram instead of a line. The built-in Open Interest

indicator has the formula:

Formula 3:

Open Interest

If this formula is created and plotted with the built-in Open Interest indicator, the values will

exactly match. So you see, your first formula is not useless, just simplistic.

How to do a Rewrite

Occasionally, your formula will not do what you want it to do. If you suspect the formula is

incorrect or you want to modify it, then you need to edit the formula. When editing a formula,

you can change any part of it, give it a new name, or even completely rewrite it.

To edit your first formula:

1) Open the Indicator Builder

2) Click on the indicator named Closing Price

3) Click the Edit button

You should see the same window you saw when you first created this formula. Notice that the

word “close” is capitalized even though you probably typed it in lower case, as shown in the

example. This is because MetaStock automatically capitalizes the names of all functions and

data arrays. You do not need to worry about capitalization. As long as the spelling is correct,

MetaStock will take care of most of the rest. You still need to provide the logic, however.

Here is a shortcut for entering the most common data arrays. The price fields of securities can

have their names abbreviated. You could have replaced the word “close” in Formula 1 with the

letter “c”. Below is a table of the different price data arrays and their abbreviations:

Open O

High H

Low L

Close C

Volume V

Open Interest OI

Either the letter or the full price field name can be used interchangeably. In future formulas, for

simplicity, this text will use just the letter. If at any time you are confused by an abbreviation,

check the table to see what value is being used.

These shortcuts work because the letters are known by MetaStock as keywords. A keyword is a

letter or word stored in an internal dictionary by MetaStock. Everything typed in the formula

window has to be a number, an operator, or a keyword.

EXCEPTION: Anything typed between curly brackets { }, will be ignored by MetaStock. Such

text is called a comment. Comments are used to give instructions and leave notes about the

formula. Comments are not used in the formulas written in this text. They are mentioned so you

will understand them if seen in other formulas.

Adding all this together

Obviously, if you want your custom indicators to do more than display the data of a price field

you need to do something with that data. Perhaps the easiest solution is to ignore it, but then you

would not have bought MetaStock to begin with. The second choice is basic math, similar to

what you learned in grade school.

Don’t worry if math is not your strong suit. This time you get to be the teacher and your student,

MetaStock, knows the answers to all of your questions. Your only problem is how to phrase the


Exercise 1:

Suppose you wanted to know a range of prices and wanted that plotted as an indicator. Here, the

range is defined as the difference between the highest price and lowest price for each period.

How would you do it? Write a formula to do this and name it Daily Range. Look at Formula 4

for the answer.

Formula 4:

At first, many formulas may seem cryptic. Therefore, all the formulas created in these exercises

will include an English “translation.” Here is the translation for formula 4.

Formula 4 in English

The value in the high data field minus the value in the low data field.

The MetaStock formula language accepts all the basic arithmetic operations. You can add,

subtract, multiply, and divide the data anyway you like. Just write out the equation and

MetaStock will solve it for you when you plot the indicator.

Your keyboard has the plus and minus signs ( + , - ), but where are the division and

multiplication symbols? The x you used in school gives some error about an unrecognized

function and the “divided by” sign just does not exist.

Welcome to the world of computer math. Because computers do not have the desired and

familiar symbols on their keyboards, other symbols are used in their place. The multiplication

symbol is replaced by an asterisk ( * ) and the division symbol is replaced by a slash ( / ).

Exercise 2:

Here's a real challenge for you. You want to see the dollar value of a future contract and your

data provider only gives the security's prices in points. Short of getting a new data vendor, what

can you do? Well, if you know that one point is equal to five dollars, you can create an indicator

to display the equivalent cash price. Write a formula to do this and name it Cash Price. Look at

Formula 5 for the answer.

Formula 5:

Formula 5 in English

The closing price multiplied by 5

If you are not familiar with the futures market, the last example may not have made much sense

to you. In that case, please look at the following.

Exercise 3:

The volume in MetaStock’s data files is usually divided by 100 before the value is stored. How

can you see the actual volume of a security? Write a formula to do this and name it True

Volume. Look at formula 6 for the answer.

Formula 6:

Formula 6 in English

Volume multiplied by 100