## Популярные книги

# Reaction

SYNTAX reaction()

This will return a +1 whenever a reaction occurs. It will continue to return this same value until

either a Rally, an Inside day, or an Outside day occur. At any time where Reaction() is not equal

to +1, it will be equal to 0.

A reaction day occurs when today's high is less than or equal to the previous day's high and

today's low is less than the previous day's low.

Reaction With Volume

SYNTAX reactionwithvol()

This will return a +1 whenever a reaction with volume occurs. It will continue to return this

same value until either a Rally, an Inside day, or an Outside day occur. At any time where

Reaction() is not equal to +1, it will be equal to 0.

A reaction with volume occurs when today's high is less than or equal to the previous day's high

and today's low is less than the previous day's low. Today's volume must also be greater than the

previous day's volume.

Reference

SYNTAX ref( DATA ARRAY, PERIODS )

This returns the value of DATA ARRAY on a previous or subsequent period. The time to be

accessed is expressed by PERIODS. A negative number looks back in time while a positive

number looks into the future. For example

Ref( C, -1 )

This function looks at the previous periods closing price.

Please be aware that using a positive value results in a formula that is not calculable on the final

periods of a chart. If there is not sufficient data in the direction being referenced, the formula

will not be calculated for that period of time. Therefore, explorations and system test that use

reference with positive numbers will not work.

A positive number of PERIODS should normally only be used in pattern recognition formulas

and even then are not suggested for explorations or system tests. For more information on

Reference, please refer to chapter 1.

Relative Momentum Index

SYNTAX rmi( DATA ARRAY, PERIODS, MOMENTUM PARAMETER )

This calculates the value of the Relative Momentum Index. It is not normally used in formulas

except to compare the value of this indicator with some other value.

Relative Strength Index (RSI)

SYNTAX rsi( PERIODS )

This calculates the value of the Relative Strength Index. It is not normally used in formulas

except to compare the value of this indicator with some other value.

Relative Volatility Index

SYNTAX rvi( PERIODS )

This calculates the value of the Relative Volatility Index. It is not normally used in formulas

except to compare the value of this indicator with some other value.

Round

SYNTAX round( DATA ARRAY )

This rounds DATA ARRAY to the nearest integer (i.e., no decimal places ). Any number with

decimal value of .5 or higher is rounded up. All others are rounded down.

Security Data

SYNTAX security("SYMBOL",DATA ARRAY)

This extremely useful function is only available in MetaStock Professional, version 7.0 or later.

It allows you to reference any value from another securities data. You can also nest other

functions in this one, allowing you to get the values for indicators calculated on other securities.

This function is more fully discussed in Chapter 5. Please look there for more details on its use.

Selling Pressure

SYNTAX sellp()

This calculates the value of the selling presure component of the Demand Index. It is not

normally used in formulas except to compare the value of this indicator with some other value.

Sine

SYNTAX sin( DATA ARRAY )

Calculates the geometric function Cosine. This is a cyclic line alternating between 0 and

1 base on the angle value used for the DATA ARRAY. Any number larger that 360, has 360

subtracted from it until it is between 1 and 360 and then the function is calculated.

Normally this function is not used in formulas but it is useful to plot or watch a cycle on a

chart. For example:

Sin( Cum( 1 ) )

With this function, 1 will be added constantly and each period the Sine() plot will

continue in its cycle. After 360 periods, it will be back to its original value, thus marking a 360

period cycle on your chart or in your formula.

To work with smaller time periods, increase the number in the Cum() function so it

reaches 360 sooner. The exact number to use can be found by the equation:

360 / number of periods in cycle

You could even put it in your formula that way. For example, if the security had a 17

period cycle, you could write:

Sin( Cum( 360 / 17 ) )

Square Root

SYNTAX sqrt( DATA ARRAY )

This calculates the square root of DATA ARRAY. The square root of a negative number always

returns a zero result.

Standard Deviation

SYNTAX stdev( DATA ARRAY, PERIODS )

This calculates the value of the Standard Deviation indicator. It is not normally used in formulas

except to compare the value of this indicator with some other value.

Standard Error

SYNTAX ste( DATA ARRAY, PERIODS )

This calculates the value of the Standard Error inidicator. It is not normally used in formulas

except to compare the value of this indicator with some other value.

Standard Error Band Bottom

SYNTAX stebandbot( DATA ARRAY, PERIODS, ERRORS )

This calculates the value of the bottom Standard Error Band of the specified DATA ARRAY.

The result is shifted downward by the number of standard errors specified by ERRORS

Standard Error Band Top

SYNTAX stebandbot( DATA ARRAY, PERIODS, ERRORS )

This calculates the value of the top Standard Error Band of the specified DATA ARRAY. The

result is shifted upward by the number of standard errors specified by ERRORS.

Stochastic Momentum Index

SYNTAX stochmomentum( PERIODS, SMOOTHING, DOUBLE SMOOTHING )

This calculates the value of the Stochastic Momentum Index. It is not normally used in formulas

except to compare the value of this indicator with some other value.

Stochastic Oscillator

SYNTAX stoch( %K PERIODS, %K SLOWING )

This calculates the value of the Stochastic Oscillator indicator. It is not normally used in

formulas except to compare the value of this indicator with some other value.

Subtraction

SYNTAX sub( DATA ARRAY, DATA ARRAY )

This function is the long way to subtract one value from another. Writing:

sub( 10, 2 )

is exactly the same as writing

10 - 2

The MetaStock formula language will treat them exactly the same. Feel free to use whichever

you are most comfortable with.

Summation

SYNTAX sum( DATA ARRAY, PERIODS )

This function totals the values for DATA ARRAY over the last PERIODS number of records. It

is important to note that this result includes the records for the date it is being calculated for. For

more information on this function, please refer to Chapter 4.

Swing Index

SYNTAX swing( LIMIT MOVE )

This calculates the value of the Swing Index. It is not normally used in formulas except to

compare the value of this indicator with some other value. Please note that the Swing Index

requires opening prices

Tema

SYNTAX tema( DATA ARRAY, PERIODS )

This calculates the value of the Tema indicator. It is not normally used in formulas except to

compare the value of this indicator with some other value.

Theta

SYNTAX theta( TYPE, DATE, PRICE, INTEREST, DIVIDEND )

This calculates the value of the Theta indicator. It is not normally used in formulas except to

compare the value of this indicator with some other value.

TYPE specifies whether the underlying security is an Equity or a Future (i.e., E or F). It also

specifies whether the option is a Put or a Call (i.e., P or C). Valid types are EC, EP, FC, and FP.

(These can be spelled out as CALL, PUT, FUTURECALL, and FUTUREPUT.)

DATE refers to the date that the option expires. The date must be formatted as YYMMDD. For

example, December 31, 1996, should be entered as 961231.

The PRICE parameter specifies the option's strike price.

The INTEREST parameter specifies a "risk free" market interest rate (e.g., 8.75). The yeild on a

3 or 6 month T-Bill is usually a good choice.

The DIVIDEND parameter specifies the total dividends received over the last 12 months.

An example of this function would be:

theta( EC, 961220, 125, 7.50, 4.75 )

This would calculate the theta of a call option on an equity with an expiration date of December

20, 1996 and a strike price of 125. The interest rate is 7.50 percent and the equity has paid $4.75

in the last 12 months.

Time Series Forecast

SYNTAX tsf( DATA ARRAY, PERIODS )

This calculates the value of the Time Series Forecast indicator. It is not normally used in

formulas except to compare the value of this indicator with some other value.

Trade Volume Index

SYNTAX tvi( MINIMUM TICK )

This calculates the value of the Trade Volume Index. It is not normally used in formulas except

to compare the value of this indicator with some other value.

TRIX

SYNTAX trix( PERIODS )

This calculates the value of the TRIX indicator. It is not normally used in formulas except to

compare the value of this indicator with some other value.

Trough Bars Ago

SYNTAX troughbars( Nth, DATA ARRAY, % MINIMUM CHANGE)

This function calculates how many periods have passed since a trough in the specified DATA

ARRAY has occurred. The Nth value is the number of troughs back to count. The %

MINIMUM CHANGE is use by the Zig Zag function to calculate when a trough has occurred.

For more information on the Zig Zag, please refer to chapter 5.

Trough Value

SYNTAX trough( Nth, DATA ARRAY, % MINIMUM CHANGE )

Using the Zig Zag function, this calculates the value DATA ARRAY had at a trough. How

many troughs back to reference is contained in the Nth parameter. %MINIMUM CHANGE is

used by the Zig Zag in calculating the peaks and troughs. For more information on the Zig Zag,

please refer to Chapter 5.

Typical Price

SYNTAX typical()

This calculates the value of the Typical Price indicator. It is not normally used in formulas

except to compare the value of this indicator with some other value.

Ultimate Oscillator

SYNTAX ult( CYCLE1, CYCLE2, CYCLE3 )

This calculates the value of the Ultimate Oscillator indicator. It is not normally used in formulas

except to compare the value of this indicator with some other value.

The parameters are three cycle lengths, each of which must be larger than the previous. In other

words, the following example will not work:

Ult ( 10, 7, 5 )

However, if the parameters were rearranged as follows, the function would calculate correctly

Ult ( 5, 7, 10 )

Using cycle lengths of 7, 14, and 21 returns the default Ultimate Oscillator.

Value When

SYNTAX valuewhen ( Nth, EXPRESSION, DATA ARRAY )

This looks at all the data in the chart and evaluates when the EXPRESSION was true. Then

starting from the most recent, it counts back Nth times and reports the value of DATA ARRAY.

For example:

ValueWhen( 1, Cross( -20, Willr(14), C )

This function returns the value of the close on the most recent occurrence of the Williams %R

falling below -20

Variance

SYNTAX var( DATA ARRAY, PERIODS )

This function examines the DATA ARRAY and calculates the statistical variance over

PERIODS number of records.

Vega

SYNTAX vega( TYPE, DATE, PRICE, INTEREST, DIVIDEND )

This calculates the value of the Vega indicator. It is not normally used in formulas except to

compare the value of this indicator with some other value.

TYPE specifies whether the underlying security is an Equity or a Future (i.e., E or F). It also

specifies whether the option is a Put or a Call (i.e., P or C). Valid types are EC, EP, FC, and FP.

(These can be spelled out as CALL, PUT, FUTURECALL, and FUTUREPUT.)

DATE refers to the date that the option expires. The date must be formatted as YYMMDD. For

example, December 31, 1996, should be entered as 961231.

The PRICE parameter specifies the option's strike price.

The INTEREST parameter specifies a "risk free" market interest rate (e.g., 8.75). The yeild on a

3 or 6 month T-Bill is usually a good choice.

The DIVIDEND parameter specifies the total dividends received over the last 12 months.

An example of this function would be:

.

Vega( EC, 961220, 125, 7.50, 4.75 )

This would calculate the vega of a call option on an equity with an expiration date of December

20, 1996 and a strike price of 125. The interest rate is 7.50 percent and the equity has paid $4.75

in the last 12 months.

Vertical Horizontal Filter

SYNTAX vhf( DATA ARRAY, PERIODS )

This calculates the value of the Vertical Horizonal Filter indicator. It is not normally used in

formulas except to compare the value of this indicator with some other value.

Volatility, Chaikin's

SYNTAX vol( MA PERIODS, ROC PERIODS )

This calculates the value of the Chaikin’s Volatility indicator. It is not normally used in

formulas except to compare the value of this indicator with some other value.

Volatility, Option

SYNTAX volo()

This calculates the value of the Option Volatility indicator. It is not normally used in formulas

except to compare the value of this indicator with some other value.

Volume Oscillator

SYNTAX oscv( PERIODS, PERIODS, MA_METHOD, DIFF_METHOD)

This calculates the value of the Volume Oscillator indicator. It is not normally used in formulas

except to compare the value of this indicator with some other value.

Two separate time periods are required for the moving averages used by this function. A moving

average method is also required, as is the method of displaying the results.

Valid MA_METHODs are SIMPLE, EXPONENTIAL, WEIGHTED, TIMESERIES,

TRIANGULAR, and VARIABLE (these can be abbreviated as S, E, W, T, TRI, and VAR).

Valid DIFF_METHODs are PERCENT and POINTS (these can be abbreviated as % and $).

Weighted Close

SYNTAX wc()

This calculates the value of the Weighted Close indicator. It is not normally used in formulas

except to compare the value of this indicator with some other value.

Wilder's Smoothing

SYNTAX wilders( DATA ARRAY, PERIODS )

This calculates the value of the Wilder’s Smoothing indicator. This is very similar to the

standard exponential moving average and can be used anywhere that type f moving average is

desired. This function also has to be used anytime one of Wilder’s custom formulas are being

written.

Williams' %R

SYNTAX willr( %R PERIODS )

This calculates the value of the William’s %R indicator. It is not normally used in formulas

except to compare the value of this indicator with some other value.

Williams' A/D

SYNTAX willa()

This calculates the value of the Williams’ A/D indicator. It is not normally used in formulas

except to compare the value of this indicator with some other value.

Writeif

SYNTAX WriteIf( EXPRESSION, "TRUE TEXT", "FALSE TEXT" )

This function can only be used within the expert advisor as part of a commentary. It functions

just like a regular If() function except it displays text instead of a value. For more information of

the If() function, please refer to chapter 2.

Expert Advisors are not discussed in this text. For more information on writing commentaries,

refer to you MetaStock manual.

Writeval

SYNTAX writeval( DATA ARRAY )

This function can only be used within the expert advisor as part of a commentary. It will display

the contents of DATA ARRAY as text.

Expert Advisors are not discussed in this text. For more information on writing commentaries,

refer to you MetaStock manual.

Year

SYNTAX year()

This function will return the value of the year in a four digit format. I.e., if the date this function

was calculated on was October, 15 1996, the result would be 1996.

Zig Zag

SYNTAX zig( DATA ARRAY, MINIMUM CHANGE, DIFF_METHOD )

This calculates the value of the Zig Zag indicator on the DATA ARRAY specified. MINIMUM

CHANGE is the amount required for a reversal and DIFF_METHOD is how the change is to be

calculated.

Valid DIFF_METHODs are PERCENT and POINTS (these can be abbreviated as % and $).