// VIX PRC
pd = 22 // "LookBack Period Standard Deviation High"
bbl = 20 //"Bolinger Band Length"
mult = 2.0 //"Bollinger Band Standard Devaition Up"
lb = 50 //"Look Back Period Percentile High"
ph = 0.85 //"Highest Percentile - 0.90=90%, 0.95=95%, 0.99=99%"
n = 10
//pl = 1.01 //"Lowest Percentile - 1.10=90%, 1.05=95%, 1.01=99%"
mult = max(mult,1)
mult = min(mult,5)
wvf = ((highest[pd](close)-low)/(highest[pd](close)))*100
sDev = mult * std[bbl](wvf)
midLine = average[bbl](wvf)
//lowerBand = midLine - sDev
upperBand = midLine + sDev
rangeHigh = (highest[lb](wvf)) * ph
//rangeLow = (lowest[lb](wvf)) * pl
if (wvf >= upperBand or wvf >= rangeHigh) then //or (wvf <= lowerBand or wvf <= rangeLow) then
color = 1
else
color = -1
endif
ave = average[n](wvf)
/////////////////////////////////////////
If wvf crosses over ave then
DRAWARROWUP( barindex ,wvf ) coloured( 255,0,0 )
endif
If wvf crosses under ave then
DRAWARROWDOWN( barindex ,wvf ) coloured( 0,255,0 )
endif
/////////////////////////////////////////
RETURN wvf coloured by color as "Williams Vix Fix", ave style(line,1) as " WVF Average"