I have found the 6/100 Historical Volatility indicator as spoken about in 'Street Smarts" but it has many errors when I try to compile it in metatrader 4.
Here it is
/*[[
Name := HVR
Author := podval
Link :=
podval_2002@rambler.ru
Notes := Historical Volatility Ratio 6/100
Notes := (L. Rashke)
Separate Window := Yes
First Color := Blue
First Draw Type := Line
First Symbol := 217
Use Second Data := No
Second Color := Red
Second Draw Type := Line
Second Symbol := 218
]]*/
Variable :
shift(0),
hv6(0),
hv100(0),
len(150),
prevBars(0),
mean6(0),
i(0),
mean100(0);
Arrays:
x6[6](0),
x100[100](0);
If prevBars = Bars Then Exit;
prevBars = Bars;
SetLoopCount(0);
For shift = 0 To Bars-1-len Begin
for i = 0 to 5
{
x6[i] = log(Close[shift+i]/Close[shift+i+1]);
};
for i = 0 to 99
{
x100[i] = log(Close[shift+i]/Close[shift+i+1]);
};
mean6 = 0;
for i = 0 to 5
{
mean6 = mean6 + x6[i];
};
mean6 = mean6/6;
mean100 = 0;
for i = 0 to 99
{
mean100 = mean100 + x100[i];
};
mean100 = mean100/100;
hv6 = 0;
for i = 0 to 5
{
hv6 = hv6 + (x6[i] - mean6)*(x6[i] - mean6);
};
hv6 = sqrt(hv6/5)*7.211102550927978586238442534941;
hv100 = 0;
for i = 0 to 99
{
hv100 = hv100 + (x100[i] - mean100)*(x100[i] - mean100);
};
hv100 = sqrt(hv100/99)*7.211102550927978586238442534941;
SetIndexValue(shift, hv6/hv100);
End;
I was wondering whether someone could fix the errors so that it can be used in metatrader4 and post the indicator so that we all can use it.
Thanks in advance