Historical & Intraday Annual Volatility

pankajpari

RSITradeMaster
#1
Hi All,
I need help in coding the Historical Annual Volatility and the Intraday Annual Volatility in AmiBroker. The formula for the same is mentioned below,

Historical Annual Volatility :
HAV Returns = Log( Current Close / Previous Close);
HAV Current Daily Volatility = SQRT(( 0.94 * (HAV Previous Daily Volatility^2)) + ( 0.06 * (HAV Returns^2)));
(The first ‘HAV Previous Daily Volatility’ can be Zero.)
Historical Annual Volatility = HAV Current Daily Volatility * SQRT( 365);

Intraday Annual Volatility :
IAV Returns = Log( Current High / Current Low);
IAV Current Daily Volatility = SQRT(( 0.94 * (IAV Previous Daily Volatility^2)) + ( 0.06 * (IAV Returns^2)));
(The first ‘IAV Previous Daily Volatility’ can be Zero.)
Intraday Annual Volatility = IAV Current Daily Volatility * SQRT( 365);

Thnx.
 

colion

Active Member
#2
Hi All,
I need help in coding the Historical Annual Volatility and the Intraday Annual Volatility in AmiBroker. The formula for the same is mentioned below,

Historical Annual Volatility :
HAV Returns = Log( Current Close / Previous Close);
HAV Current Daily Volatility = SQRT(( 0.94 * (HAV Previous Daily Volatility^2)) + ( 0.06 * (HAV Returns^2)));
(The first HAV Previous Daily Volatility can be Zero.)
Historical Annual Volatility = HAV Current Daily Volatility * SQRT( 365);

Intraday Annual Volatility :
IAV Returns = Log( Current High / Current Low);
IAV Current Daily Volatility = SQRT(( 0.94 * (IAV Previous Daily Volatility^2)) + ( 0.06 * (IAV Returns^2)));
(The first IAV Previous Daily Volatility can be Zero.)
Intraday Annual Volatility = IAV Current Daily Volatility * SQRT( 365);

Thnx.
Substitute as follows:

Current Close = C
Previous Close = Ref( C, -1 )
HAV Previous Daily Volatility = Ref( HAV, -1 )
 

pankajpari

RSITradeMaster
#3
Hi Colion,
Tried the same, but I get the error "Variable CHAV used without having been initialised".
Pls find below the code used :

CReturns = ln(C / Ref( C, -1));
CHAV = sqrt(( 0.94 * (Ref( CHAV, -1)^2)) + ( 0.06 * (CReturns^2)));

Kindly look into the same. Thnx.
 
#4
Hi Colion,
Tried the same, but I get the error "Variable CHAV used without having been initialised".
Pls find below the code used :

CReturns = ln(C / Ref( C, -1));
CHAV = sqrt(( 0.94 * (Ref( CHAV, -1)^2)) + ( 0.06 * (CReturns^2)));

Kindly look into the same. Thnx.
Initialize the variables used, it can be usually done by hard coding the first value for the arrays. in the above case it can be

Code:
CHAV[0] = 1;
 
#6
HI ,
I tried this formula to display the volatility along with the graph but it fails.
This keeps showing different numbers some times in few thousands and some times less than 10.


Can you please let me know what am i missing here.