//------------------------------------------------------------//
//PRC_RVM Relative Volatility Measure
//version = 0
//12.04.24
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//------------------------------------------------------------//
//-----Inputs--------------------------------------------------//
lookbackPeriod=15//Lookback Period
showBgColor = 1//Show Background Color
//------------------------------------------------------------//
//-----Short Term ATRs calculation----------------------------//
short1=averagetruerange[3]
short2=averagetruerange[5]
short3=averagetruerange[8]
shortAvg=(short1+short2+short3)/3
//------------------------------------------------------------//
//-----Long Term ATRs calculation-----------------------------//
Long1=averagetruerange[55]
Long2=averagetruerange[89]
Long3=averagetruerange[144]
LongAvg=(Long1+Long2+Long3)/3
//------------------------------------------------------------//
//-----Combined ATR value-------------------------------------//
combinedATR = (shortAvg + longAvg) / 2
//------------------------------------------------------------//
//-----Highest and lowest combined ATR over lookbackPeriod----//
highestCombinedATR = highest[lookbackPeriod](combinedATR)
lowestCombinedATR = lowest[lookbackPeriod](combinedATR)
//------------------------------------------------------------//
//-----RVM Calculation----------------------------------------//
rvm = (combinedATR - lowestCombinedATR) / max(highestCombinedATR - lowestCombinedATR, 0.001) * 100
//------------------------------------------------------------//
//-----Background color conditions----------------------------//
if showBgColor and rvm>=0 and rvm <=10 then
backgroundcolor(21,216,34,85)
elsif showBgColor and rvm>10 and rvm<=20 then
backgroundcolor(37,214,238,85)
endif
//------------------------------------------------------------//
return rvm as "RVM"coloured("blue")style(line,2),50 as "Midpoint"coloured("grey")style(dottedline),20 as "Midpoint"coloured(37,214,238)style(dottedline),10 as "Midpoint"coloured(21,216,34)style(dottedline)