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

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

Roll Your own Indexes

A second use of the p variable is to create a custom index. The MetaStock software, by itself,

can add only two securities together. This is done with a composite in the DownLoader. It can

only combine two regular security data files and nothing you do in the MetaStock or the

DownLoader can increase that. Except a custom formula using the p variable.

Normally, an index has more than two securities in it. Most have eight or more. To make a

custom index of any number of securities, use the following steps. The example will use only

eight securities named A, B, C, D, E, F, G and H.

1. In the DownLoader create four composites. Choose Add as the operation for each composite.

For this example the resulting composites are called AB, CD, EF, and GH. Note: both

components of a given composite must be in the same directory.

2. In MetaStock, open up all four composites. Choose Window | Stack to show them all on the

screen at one time. Note: make sure that 'Remove Existing Charts' is not selected under

File | Open when opening the charts.

3. Create a custom indicator containing the formula C+P

4. Click on the CD plot and drag it onto the same chart as the AB composite. Close the CD

chart.

5. Drag the C+P indicator and drop it onto the CD plot. Note: before dropping the indicator,

make sure the CD plot turns magenta. When you see the scaling menu, choose 'Overlay

without scale'.

6. Drag the resulting plot and drop in into the EF chart. Close the AB chart.

7. Drag the C+P indicator and drop it onto the new indicator plot in the EF chart. Note: before

dropping the indicator, make sure the other indicator plot turns magenta. When you see the

scaling menu, choose 'Overlay without scale'.

8. Drag the resulting plot onto the GH chart. Close the EF chart.

9. Drag the C+P indicator and drop it onto the new indicator plot in the GH chart. Note: before

dropping the indicator, make sure the other indicator plot turns magenta. When you see the

scaling menu, choose 'Overlay without scale'.

10. The resulting plot is the end result. You can take this plot and drop it into any chart that you

would like. MetaStock automatically remembers what components were used to calculate it.

It will automatically be updated from the information in all eight securities

Warning: P at work

The p variable has its limits. When it is plotted on a security’s prices, it assumes you want the

closing price. There is no way to make it use a different price field unless you create a custom

indicator using just that price field.

Once you plot an indicator using p, you cannot change what p refers to unless you plot the

indicator in the chart again, making sure the desired plot is colored magenta.

You also cannot refer to two different plots in the same formula. P always has the same value

through the formula, no matter how many times or places you use it.

Acknowledging these restrictions, the p variable can still be very helpful. The custom index

alone makes p extremely valuable. As you work with the MetaStock formula language, you are

likely to find other uses. Don’t be afraid to experiment, but remember the variable’s limitations.