Monthly Volatility Rating
Forums › ProRealTime English forum › ProBuilder support › Monthly Volatility Rating
- This topic has 0 replies, 1 voice, and was last updated 5 years ago by Vonasi.
-
-
09/03/2019 at 11:45 AM #106352
As part of my research into taking trading holidays I decided to write an indicator to rank months by their volatility. I decided that true range + body size would be an interesting basis for the volatility.
The indicator checks every bar in every month and then ranks each month with a score from 0 to 100 with 100 being the most volatile month and 0 the least volatile.
In the attached image of the DAX daily we can see that October is the most volatile and April the least volatile. January, March, August and September are above the average volatility and all the other months are below it. How far above and below in relation to the other months can be easily seen thanks to the 0 to 100 rating.
The results could be used in other ways such as possibly increasing or decreasing take profit and stop loss sizes each month based on the months volatility rating.
I post the indicator here just in case it is of any use to anyone.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145//Monthly volatility rating//Based on true range and body size//By Vonasi//20190903if barindex > 1 thenif openmonth = 1 thenjan = jan + 1jantr = jantr + trjanbody = janbody + (abs(close - open))endifif openmonth = 2 thenfeb = feb + 1febtr = febtr + trfebbody = febbody + (abs(close - open))endifif openmonth = 3 thenmar = mar + 1martr = martr + trmarbody = marbody + (abs(close - open))endifif openmonth = 4 thenapr = apr + 1aprtr = aprtr + traprbody = aprbody + (abs(close - open))endifif openmonth = 5 thenmay = may + 1maytr = maytr + trmaybody = maybody + (abs(close - open))endifif openmonth = 6 thenjun = jun + 1juntr = juntr + trjunbody = junbody + (abs(close - open))endifif openmonth = 7 thenjul = jul + 1jultr = jultr + trjulbody = julbody + (abs(close - open))endifif openmonth = 8 thenaug = aug + 1augtr = augtr + traugbody = augbody + (abs(close - open))endifif openmonth = 9 thensep = sep + 1septr = septr + trsepbody = sepbody + (abs(close - open))endifif openmonth = 10 thenoct = oct + 1octtr = octtr + troctbody = octbody + (abs(close - open))endifif openmonth = 11 thennov = nov + 1novtr = novtr + trnovbody = novbody + (abs(close - open))endifif openmonth = 12 thendec = dec + 1dectr = dectr + trdecbody = decbody + (abs(close - open))endifcount = count + 1all = all + trallave = all/countallb = allb + (abs(close - open))allaveb = allb/countavjan = jantr/janavfeb = febtr/febavmar = martr/maravapr = aprtr/apravmay = maytr/mayavjun = juntr/junavjul = jultr/julavaug = augtr/augavsep = septr/sepavoct = octtr/octavnov = novtr/novavdec = dectr/decavjanb = janbody/janavfebb = febbody/febavmarb = marbody/maravaprb = aprbody/apravmayb = maybody/mayavjunb = junbody/junavjulb = julbody/julavaugb = augbody/augavsepb = sepbody/sepavoctb = octbody/octavnovb = novbody/novavdecb = decbody/decendifjanrate = ((avjan + avjanb)/count)febrate = ((avfeb + avfebb)/count)marrate = ((avmar + avmarb)/count)aprrate = ((avapr + avaprb)/count)mayrate = ((avmay + avmayb)/count)junrate = ((avjun + avjunb)/count)julrate = ((avjul + avjulb)/count)augrate = ((avaug + avaugb)/count)seprate = ((avsep + avsepb)/count)octrate = ((avoct + avoctb)/count)novrate = ((avnov + avnovb)/count)decrate = ((avdec + avdecb)/count)allrate = ((allave + allaveb)/count)upper = max(decrate,max(novrate,max(octrate,max(seprate,max(augrate,max(julrate,max(junrate,max(mayrate,max(aprrate,max(marrate,max(janrate,febrate)))))))))))lower = min(decrate,min(novrate,min(octrate,min(seprate,min(augrate,min(julrate,min(junrate,min(mayrate,min(aprrate,min(marrate,min(janrate,febrate)))))))))))janratep = ((janrate - lower)/(upper-lower))*100febratep = ((febrate - lower)/(upper-lower))*100marratep = ((marrate - lower)/(upper-lower))*100aprratep = ((aprrate - lower)/(upper-lower))*100mayratep = ((mayrate - lower)/(upper-lower))*100junratep = ((junrate - lower)/(upper-lower))*100julratep = ((julrate - lower)/(upper-lower))*100augratep = ((augrate - lower)/(upper-lower))*100sepratep = ((seprate - lower)/(upper-lower))*100octratep = ((octrate - lower)/(upper-lower))*100novratep = ((novrate - lower)/(upper-lower))*100decratep = ((decrate - lower)/(upper-lower))*100allratep = ((allrate - lower)/(upper-lower))*100return janratep as "jan rating", febratep as "feb rating", marratep as "mar rating", aprratep as "apr rating", mayratep as "may rating", junratep as "jun rating", julratep as "jul rating", augratep as "aug rating", sepratep as "sep rating", octratep as "oct rating", novratep as "nov rating", decratep as "dec rating", allratep as "all rate"//avjanb as "jan b", avfebb as "feb b", avmarb as "mar b", avaprb as "apr b", avmayb as "may b", avjunb as "jun b", avjulb as "jul b", avaugb as "aug b", avsepb as "sep b", avoctb as "oct b", avnovb as "nov b", avdecb as "dec b", allaveb coloured(0,0,255) as "all b", avjan as "jan", avfeb as "feb", avmar as "mar", avapr as "apr", avmay as "may", avjun as "jun", avjul as "jul", avaug as "aug", avsep as "sep", avoct as "oct", avnov as "nov", avdec as "dec", allave coloured(0,0,255) as "all", -
AuthorPosts