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.
//Monthly volatility rating
//Based on true range and body size
//By Vonasi
//20190903
if barindex > 1 then
if openmonth = 1 then
jan = jan + 1
jantr = jantr + tr
janbody = janbody + (abs(close - open))
endif
if openmonth = 2 then
feb = feb + 1
febtr = febtr + tr
febbody = febbody + (abs(close - open))
endif
if openmonth = 3 then
mar = mar + 1
martr = martr + tr
marbody = marbody + (abs(close - open))
endif
if openmonth = 4 then
apr = apr + 1
aprtr = aprtr + tr
aprbody = aprbody + (abs(close - open))
endif
if openmonth = 5 then
may = may + 1
maytr = maytr + tr
maybody = maybody + (abs(close - open))
endif
if openmonth = 6 then
jun = jun + 1
juntr = juntr + tr
junbody = junbody + (abs(close - open))
endif
if openmonth = 7 then
jul = jul + 1
jultr = jultr + tr
julbody = julbody + (abs(close - open))
endif
if openmonth = 8 then
aug = aug + 1
augtr = augtr + tr
augbody = augbody + (abs(close - open))
endif
if openmonth = 9 then
sep = sep + 1
septr = septr + tr
sepbody = sepbody + (abs(close - open))
endif
if openmonth = 10 then
oct = oct + 1
octtr = octtr + tr
octbody = octbody + (abs(close - open))
endif
if openmonth = 11 then
nov = nov + 1
novtr = novtr + tr
novbody = novbody + (abs(close - open))
endif
if openmonth = 12 then
dec = dec + 1
dectr = dectr + tr
decbody = decbody + (abs(close - open))
endif
count = count + 1
all = all + tr
allave = all/count
allb = allb + (abs(close - open))
allaveb = allb/count
avjan = jantr/jan
avfeb = febtr/feb
avmar = martr/mar
avapr = aprtr/apr
avmay = maytr/may
avjun = juntr/jun
avjul = jultr/jul
avaug = augtr/aug
avsep = septr/sep
avoct = octtr/oct
avnov = novtr/nov
avdec = dectr/dec
avjanb = janbody/jan
avfebb = febbody/feb
avmarb = marbody/mar
avaprb = aprbody/apr
avmayb = maybody/may
avjunb = junbody/jun
avjulb = julbody/jul
avaugb = augbody/aug
avsepb = sepbody/sep
avoctb = octbody/oct
avnovb = novbody/nov
avdecb = decbody/dec
endif
janrate = ((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))*100
febratep = ((febrate - lower)/(upper-lower))*100
marratep = ((marrate - lower)/(upper-lower))*100
aprratep = ((aprrate - lower)/(upper-lower))*100
mayratep = ((mayrate - lower)/(upper-lower))*100
junratep = ((junrate - lower)/(upper-lower))*100
julratep = ((julrate - lower)/(upper-lower))*100
augratep = ((augrate - lower)/(upper-lower))*100
sepratep = ((seprate - lower)/(upper-lower))*100
octratep = ((octrate - lower)/(upper-lower))*100
novratep = ((novrate - lower)/(upper-lower))*100
decratep = ((decrate - lower)/(upper-lower))*100
allratep = ((allrate - lower)/(upper-lower))*100
return 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",