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" ) ;
You did help, and its been about five years since I last did all these calculations, hence my propensity towards making these mistakes. During that time I have traded several volatility based models that have done fairly well and I can assure you that the point is to create a good trading model, but, one has to go through these figuring out steps first. This "clustering" indicator is this threads creation (thanks dtrader), and I'm trying to move the process along. Note, I've done this before and other than the possibility of finding a good idea that I haven't seen, the personal benefit to me is minimal. My hope is to introduce this way of development because it is very rewarding. Lets just stick with what we have coded up and move on to: 2. Invent a hypothesis, i.e. explanation. 3. Assign rules that confirm/deny your hypothesis. Thoughts?
Been following this thread with interest lately. Can't really figure out where exactly you're trying to lead to with this "vola clustering" study... Don't have TS, but you're declaring the variable "j" and not using it afterwards seems suspicious to me. Shouldn't it be s'thing like this instead? Code: if time >= 605 and time <= 1400 then begin for j=0 to 11 begin return[j] = Square(h[j] - l[j]); end; end; sum= 0; for j=0 to 11 begin sum= sum + return[j]; end; ssr = squareroot(sum);
Thanks cfd, This is much better code, I suggest everyone use it instead. Yes, I admit, I suck at writing good code, haha. Oh well. See my prior post to where this is leading. Do you have any thoughts about this indicator? How about a trading rule or hypothesis we can test?
Mike, afaiac being an intraday trader I don't really care all that much as to what happened overnight - so maybe I'm not in the best place to participate to this discussion, dunno... Though one might be able to find some sort of correlation b/w overnight volatility and intraday volatility the next day... For instance when there's a relatively large move overnight (it's all "relative", right? ), 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. But I haven't run that hypothesis thru verification - not yet anyway, though it might turn out being an interesting "root" for a potential trading system... Other than that, it would seem to me that continuously measuring bar ranges (H-L) over various periods (eg 1mn, 2mns, 5mns, 15mns), comparing them, and computing things like mean/avg/standard dev/... might help towards the goal of creating a "vola clustering index". Just a thought, needs to be refined (euphemism ^^). Btw even after reading your previous post I'm still unclear as to how you would want to use such an indicator, or to turn it into a system... It's called "being dense" I believe... lol
Mike, I think a little confusion remains because the indicator is being called a "clustering" indicator but it doesn't appear to measure that effect, just realized vol. Are you looking for us to run tests on this vol measure to prove that clustering exists? Or rather use the knowledge that clustering exists in conjunction with this indicator to creating trading rules?
Very good point and I should have explained better. This indicator is a way to measure realized vola as you have pointed out, but the lag provides history. The clustering effect is another way of identifying prolonged periods of high or low volatility. At this point, IMO, whether or not this indicator measures clustering is a semantic issue. If we say "a period of high vola followed by high vol" then, when this indicator value stays high, or is higher than some predetermined quantity we have an hourly measure of prolonged higher vola and vice versa for low vola. After all this indicator has lag... Again, this depends how one defines clustering and at this point, it doesn't really matter if we are overly specific, all we need is a way to ID higher vola over a period of time, not over just one bar. I've choosen 1 hour here in a 5 min bar. In terms of trading rules, you have all pertinent information you need at this point: 1. Volatility is mean reverting as I showed in an Excel analysis a while back. 2. Also in that analysis I showed that we can capture market movement by selling low vola and by buying high vola. 3. High vola begats high vola and vice versa. 4. Lower vola = propensity for a down move greater. 5. Higher vola = propensity for a up move greater. Given these two facts, how can we create a trading rule, using our indicator (or a permutation thereof), that exploits this set of facts? Mike
Amibroker code: Vol_0 = (H - L)^2; Vol_1 = (Ref(H,-1) - Ref(L,-1))^2; Vol_2 = (Ref(H,-2) - Ref(L,-2))^2; Vol_3 = (Ref(H,-3) - Ref(L,-3))^2; Vol_4 = (Ref(H,-4) - Ref(L,-4))^2; Vol_5 = (Ref(H,-5) - Ref(L,-5))^2; Vol_6 = (Ref(H,-6) - Ref(L,-6))^2; Vol_7 = (Ref(H,-7) - Ref(L,-7))^2; Vol_8 = (Ref(H,-8) - Ref(L,-8))^2; Vol_9 = (Ref(H,-9) - Ref(L,-9))^2; Vol_10 = (Ref(H,-10) - Ref(L,-10))^2; Vol_11 = (Ref(H,-11) - Ref(L,-11))^2; VolSqd = Vol_0 + Vol_1 + Vol_2 + Vol_3 + Vol_4 + Vol_5 + Vol_6 + Vol_7 + Vol_8 + Vol_9 + Vol_10 + Vol_11; Vol = sqrt(VolSqd);
Start with something simple like this? Buy when Indicator > 90th percentile over last 500 periods Short when Indicator < 10th percentile over last 500 periods Then just reverse the entry rules for exits...?
I believe this will generate the same result as the above Amibroker code vol = sqrt(sum((h-l)^2, 12));