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

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

P Soup Anyone

There is one more variable that needs to be discussed. This last variable is a hybrid between the

price field identifiers discussed in chapter 1 and the variables just mentioned. It is referred to

only by the letter p.

The p variable takes the value of whatever plot is selected when it formula is calculated. For

example, when you are plotting a moving average in a chart, some existing plot turns a purplish /

magenta color. As soon as you let go of the mouse, the color returns to normal and the moving

average is calculated on whatever was the magenta color. You could write a moving average

formula to do the exact same thing. Consider formula 36 below.

Formula 36

Mov( p, 14, S)

The p variable is used where the data array would be specified. This tells MetaStock to calculate

the moving average using whatever plot is highlighted / selected when the formula is used.

What’s the point you may ask? Any plot on your chart can be duplicated in the MetaStock

formula language, so why use p instead of the formula for the plot?

Versatility is the major reason. If you tend to use the same formula a lot and only vary the data

array, it might be easier to write the formula once using p. You could then plot the base

calculation and apply the p variable’s indicator for the final plot.

For example; suppose you wanted to plot the MACD() or the RSI() of an indicator. Both of

these formulas automatically assume you want to use the closing price. To use an indicator, you

would have to create a custom formula and include the formula of the indicator where the close

is normally used. If you had several custom indicators you wanted to do this to, you would have

to duplicate the formula once for each indicator. Or, you could create the formula once and use

the p variable where the closing prices are used.