//PRC_WillVal-indicator | indicator
//24.11.2017
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//attempt to create the Williams Valuation Index on ProRealTime
//using spread chart (CTRL+R).
//firstly, create a spread chart with any commodity divided by gold
//then apply this indicator on a weekly timeframe of the resulted spread chart
norm = close*100
ema2weeks = average[10,1](norm) //10 days (2 weeks)
ema22weeks = average[110,1](norm) //110 days (22 weeks)
pal = ema2weeks-ema22weeks
h3 = highest[720](pal)//max(h3,pal)
l3 = lowest[720](pal)//min(l3,pal)
//if year<>year[1] then
//firstbar=barindex
//count=count+1
//if count=3 then
//maxbar=max(maxbar,barindex-firstbar)
//count=0
////h3 = pal
////l3 = pal
//endif
//endif
willval = ((pal-l3)/(h3-l3))*100
return willval coloured(0,0,255) style(line,2), 75 style(dottedline,1) as "level 75", 15 style(dottedline,1) as "level 15"