[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Usable Hist.-Volatility in Metastock



PureBytes Links

Trading Reference Links

Is there any way to code an equivalent to the Tradestation
Volatility-StdDev. (Hist.-Vola) in Metastock? The code in Easy
Language uses a For..To loop wich is AFAIK not available in Metastock?
The built-in Vola-indicators in MS ("Chaikins", "Option Vola.") seem
to deliver some strange values!?

Many thanks for your input,
ciao Jens

ok, here is the TradeStation function:

{*******************************************************************
Description	: This Function returns 	Statistical Volatility
- Standard Deviation of Closes
Provided By	: Omega Research, Inc. (c) Copyright 1999
********************************************************************}

Inputs: NumDays(Numeric);

Variables: AssetPrice(0), Answer(0), Count(0), NoData(0),
VoltyDays(0), AvgDiff(0), SumDiff(0);

If DataCompression = 2 then Begin {check for daily data}
	VoltyDays = NumDays;
	For Count = 1 To VoltyDays + 1 Begin
		AssetPrice = Close[Count]; {Check For Enough History}
		If AssetPrice = 0 then 
			NoData = 1;
	End;

{		
	If NoData = 0 Then Begin
}
		AvgDiff = Average((log(Close[0] / Close[1])),
VoltyDays);
		SumDiff = Summation(((Log(Close[0] / Close[1])) -
AvgDiff) * ((Log(Close[0] / Close[1])) - AvgDiff), VoltyDays);
		Answer = (SquareRoot(SumDiff / VoltyDays)) *
15.90957; {Annualize Calculation}
		If Answer <= 0 Then 
			Answer = 0;
		If Answer >= 2.99 Then 
			Answer = 2.99;
	End;
{
End;
}
		
VolatilityStdDev = Answer;