Quote from black diamond:
Hi Mike,
I don't think this is what you meant to do. Taking the square root of the square is just taking the absolute value. If you want to take the square root of the sum to reduce the impact of outliers I think that would make sense, but there is no point in doing this before you sum them.
Also here's a couple of observations/questions:
I haven't given it much thought before, but I noticed this and similar measures have an undesirable property when you are applying them to price changes that can take either sign. Probably simplest to give an example: this will give the same vol if all 12 values are +2 pts, or if half are +2 and half -2, even though you probably want your vol measure to distinguish between the two market states. You could get around this by demeaning the price changes (like in the basic std dev formula) or taking logs, but these have their own idiosyncracies. Do you have a preference or are you still figuring it out?
Also I don't really think you are capturing vol clustering here. It looks like you are just measuring vol over a rolling window, and your measure will be clustered by definition because each bar's vol measure has 11 datapoints in common with the adjacent bar's vol measure. If you really want to measure clustering you need non-overlapping vol observations and some time series model. But I don't think you need to for this purpose, I am just mentioning it because you keep talking about clustering.
Edit: I just re-read your post that the goal is not trade filtering. I was trying to help with the calculations but I guess I don't really get what the goal is here so maybe I should back off.
Thanks for catching this mistake - yes, I want to take the square root of the sum of values, not the square root of each one. Again I'll try to be more careful in the future about posting mistakes. Please, don't back off, any input is good input!
Clustering is just periods of high vola followed by more high vola and vice versa. The aim to use some brute force method to identify periods of extended high vola. The idea behind using a "rolling window" is that we have a lag associated with the number, meaning some history is included in the calc. We don't need a full on ARCH type model, just something simple to capture this effect.
Well, the goal is not trade filtering for now, but, I will eventually show you a use for this model in a filter in the future. I'm hoping people here would come up with it on thier own knowing what the characteristics of vola are, but, if worse comes to worse I'll spoon feed it.
Thanks for your input. TS code provided below. Also, I'm using TS because its easy to understand and quick, if someone could do it, I'd appreciate they would do this in Amibroker and post it as well.
Mike
var:
ssr(0),
j(0);
array:
return[11](0);
if time >= 605 and time <= 1400 then begin
for j=0 to 11 begin
return[0] = (Square(h[0] -l[0]));
return[1] = (Square(h[1] -l[1]));
return[2] = (Square(h[2] -l[2]));
return[3] = (Square(h[3] -l[3]));
return[4] = (Square(h[4] -l[0]));
return[5] = (Square(h[5] -l[5]));
return[6] = (Square(h[6] -l[6]));
return[7] = (Square(h[7] -l[7]));
return[8] = (Square(h[8] -l[8]));
return[9] = (Square(h[9] -l[9]));
return[10] = (Square(h[10]-l[10]));
return[11] = (Square(h[11]-l[11]));
end;
end;
ssr = squareroot(return[0]+return[1]+return[2]+return[3]+return[4]+return[5]+return[6]+return[7]+return[8]+return[9]+return[10]+return[11]);
Value1 = ssr;
Plot1( Value1, "SSR" ) ;
), thus creating an opening gap, quite often volatility dries up the next day, at least for a good part of the trading session, as if the large overnight price move needed to be "digested" by the market.