 # Metastock Formulas - V Click here to go back to Metastock Formula Index

 IMPORTANT: These formulas aren't my complete collection. For my complete collection of instantly usable, profitable and powerful MetaStock formulas Click Here

Would You Like To Use MetaStock To Its Full Potential? Discover the Amazingly Simple Secret to Master Metastock Step-By-Step - click here

A | A 1 | B | B 1 | C | C 1 | D | D 1 | E | F | G | H | I | J | K | L | M | M 1 | N | O | P | R | S | S 1 | T | U | V | W | Z |

 Variable MA Formula- Updated Vidya 21, 5 Vidya Explanation Vidya using P variable, version I Vidya with P variable, version II Volatility % Indicator Volatility Difference Volatility Trade in Gold Volatility Bands as a Long Term Strategy Volatility Over 16 Weeks Volume Accumulation Percentage Volume Based Exploration Volume Oscillator Wave

## Variable MA Formula- Updated

periods:=Input("periods",1,244,89);
VariableMA511( mp() , periods)

Equis put this function in for me. It uses VHF rather than CMO. Unlike the present version, this is better.

(Go Top)

## Vidya 21, 5

This is the MetaStock code for VIDYA 21,5 which applies to the article "Breaking Out Of Price Channels" by Gerald Marisch in the TASC January 1998 edition.

Length:=Input("Length",1,200,21);
Smooth:=Input("Smoothing",1,200,5);
AbsCMO:=(Abs(CMO(C,Length)))/100;
SC:=2/(Smooth+1);
VIDYA:=If(Cum(1)<=(Length+1),C,(SC*AbsCMO*CLOSE)+(1-(SC*AbsCMO))*PREV);
VIDYA

(Go Top)

## Vidya with P variable, version II

My version of Tushar Chande's Vidya, using the P variable

Vidya{P}
Periods:=Input("length of MA",5,100,20);
K:=Stdev(P,5)/Mov(Stdev(P,5),20,S);
A:=(2/(Periods+1));
Vidya:=A*K*(P)+(1-A*K)*Ref(P,-1);
Vidya;

Tar(SZ)an Long
C-(((462*Mov(C,34,E))-(420*Mov(C,13,E))+(490*(Mov(Mov(C,13,E)-
Mov(C,34,E),89,E))))/42)

Tar(SZ)an Short
(C-(((325*Mov(C,26,E))-(297*Mov(C,12,E))+(351*Mov(Mov(C,13,E)-
Mov(C,26,E),9,E))))/28)*2

(Go Top)

## Vidya Explanation

Vidya is a subject that comes up with some regularity. It's actually available in MetaStock as the Variable Moving Average (Mov(C,n,V) but Equis, for their own inscrutable reasons, choose not to identify it by name. If you refer to the MetaStock manual, be aware that there is a typo in the formula (0.078 should read 0.78). Two or three years ago I coded the version given in TAS&C and it overlaid the MetaStock version precisely, except that at the time the MetaStock version was not correctly initialised -- this has since been corrected. Equis acknowledged the typo at the time, but have done nothing about it.

As far as the 'circular reference' is concerned, you are right that eventually you run out of data. However adding a portion of yesterday's value to a portion of today's value is common to several indicators, such as the Exponential Moving Average. If no provision is made, then usually the indicator will start with a value of zero, rise rapidly at first, then take some time to stabilise.

One answer is to initialise it. For a Vidya of the close, period N, you can initialise with something like "If(Cum(1) < N, C,{else} ...)" with the Vidya formula as the 'else'. Then at day N the indicator uses the (N-1) close for yesterday's data and takes much less time to stabilise.

(Go Top)

## Vidya using P variable, version I

Here is a version of Vidya using a P variable that matches MetaStock's built-in Variable Moving Average. You can overlay them in different colours on the same chart to satisfy yourself that they are indeed the same (but remember to use the same number of periods). There is a small difference at the start due to different initialisation, after which they are identical. The coding is spelled out for the benefit of anyone studying the book. It can be adapted by adding a variable input for the CMO length (9), or made universal by replacing each C with a P, or the Abs(CMOsc) can be replaced with a different volatility index that ranges between 0 and 1.

{Vidya (Chande)}

Pds:= Input("Number of Periods?",1,1000,20);
Alpha:= 2/(Pds+1);

{Chande Momentum Oscillator}
{UD = Up day}
{DD = Down day}
UD:= Sum((C-Ref(C,-1))*(C>Ref(C,-1)),9);
DD:= Sum((Ref(C,-1)-C)*(C<Ref(C,-1)),9);
CMOsc:= (UD-DD)/(UD+DD);

k:= Abs(CMOsc);

Vidya:= (Cum(1) < Pds) * C + (Cum(1)>=Pds) * ((Alpha * k * C) + (1-Alpha
* k) * PREV);
Vidya

(Go Top)

## Volatility % Indicator

You can easily create the Volatility% Indicator from William Brower’s article in MetaStock for Windows. First choose Indicator Builder from the Tools menu in MetaStock. Next choose New and enter one of the following formulas:

Formula for MetaStock 6.5

Volatility%

Lookback := Input("Time Periods",1,1000,50);

HighVolatility := Input("High Volatility %",.01,100,3);

100 * Sum(100 * ATR(1)/CLOSE > HighVolatility, Lookback)/Lookback

Formula for earlier versions of MetaStock for Windows

Volatility%

100 * Sum(100 * ATR(1)/CLOSE > 3, 50)/50

Now drag the Volatility% from the Indicator QuickList and drop it on the desired chart.

(Go Top)

"A Volatility Trade In Gold" by David S. Landry, CTA, Technical Analysis of Stocks & Commodities, page 87.

In this article the author gives formulas for three indicators MetaStock. The formulas as given will work in all versions of MetaStock. However, there is an error in the formula the author names Volatility 12 EMA. The formula should be: Mov((Fml("CONHV4") + Fml("CONHV6") + Fml("CONHV10"))/3,12,e)

Here are formulas for version 6.5 and higher of MetaStock for Windows. These formulas use Inputs which allow you to select the time periods when you plot the formulas.

David Landry Historical Volatility
 Num:=Input("Number Of Periods For Numerator",1,100,4); Den:=Input("Number Of Periods For Denominator",2,1000,100); (Log(C/Ref(C,-1)),Num)/Std(Log(C/Ref(C,-1)),Den)
David Landry Average Historical Volatility
 Den:=Input("Number Of Periods For Denominator",2,1000,100); ((Std(Log(C/Ref(C,-1)),4)/Std(Log(C/Ref(C,-1)),Den))+(Std(Log(C/Ref(C,- 1)),6)/Std(Log(C/Ref(C,-1)),Den))+(Std(Log(C/Ref(C,-1)),10)/Std(Log(C/Ref(C,- 1)),Den)))/3
David Landry EMA of Historical Volatility
 Den:=Input("Number Of Periods For Denominator",2,1000,100); EMA:=Input("Number Of Periods For EMA",2,100,12); Mov(((Std(Log(C/Ref(C,-1)),4)/Std(Log(C/Ref(C,-1)),Den))+(Std(Log(C/Ref(C,- 1)),6)/Std(Log(C/Ref(C,-1)),Den))+(Std(Log(C/Ref(C,-1)),10)/Std(Log(C/Ref(C,- 1)),Den)))/3,LastValue(EMA),E)

Note: Standard deviation information was not included here because the way these formulas are being used, any standard deviation being used would return an identical value as 1 standard deviation.

(Go Top)

## Volatility Bands as a Long Term Strategy

This article "Volatility Bands As A Long Term Strategy", by Ahmet Tezel, Ph.D., and Suzan Koknar-Tezel, M.S., which appears in this issue introduces two different volatility band trading systems. One system uses bands based on moving averages and the other is based on bands which use regression. To plot the Moving Average Asymmetric Volatility Price Bands in MetaStock for Windows, simply plot Bollinger Bands using 11 periods and 1.7 standard deviations. Then click your right-mouse button while the cursor is over the lower band and choose properties. Change the standard deviations to 2. This plot will now appear exactly as the bands discussed in the article.

To plot the Regression Asymmetric Volatility Price Bands in Metastock for Windows, simply plot Standard Error Bands using 21 periods, 1 for standard errors, and 1 for the smoothing periods. Then click your right-mouse button while the cursor is over the lower band and choose properties. Change the standard errors to 1.5.

To recreate the systems in MetaStock for Windows, choose System Tester from the Tools menu. Next choose New and enter the following trading rules and stop conditions. After entering this information, choose Options and change the trade delay to 1, then change the Trade Price to Open. If you have MetaStock 6.5 enter the first set of formulas. MetaStock 6.5 allows variables which will allow you to change the periods when testing much more easily.

(Go Top)

## Volatility Over 16 Weeks

Col A: CLOSE

Col B: Vol(10,80)

Filter: Vol(10,80)>200

Filter enabled: Yes

(Go Top)

## Volume Accumulation Percentage

I contacted David Vomund by e-mail and he was kind enough to mail me the equations required to calculate the VAP. I've programmed them in MetaStock as follows:

VOLUME ACCUMULATION PERCENTAGE
Periods:=Input("Time Periods",1,60,21);
X:=(2*C-H-L)/(H-L);
TVA:=Sum(V*x,Periods);
TV:=Sum(V,Periods);
VA:=100*TVA/TV;
VA

(Go Top)

## Volume Based Exploration

1. Stocks with volume > 10x the previous day's volume

2. Stocks where the above situation hasn't occurred during the previous 60 days.

ColA = if(V > 10*ref(V,-1),1,0)

Filter: ColA=1 and ColB>60

(Go Top)

## Volatility Difference

mov(H-L,1,S)/mov(H-L,20,S)

(Go Top)

## Volume Oscillator Wave

if(oscv(1,50,S,%),>,50,1,0)

(Go Top)

If you have Metastock formulas you would like to share,
Please email to We look forward to hearing from you!