//Distribution of Index
//PRT v11 onwards
//By Vonasi
//Date: 20200509
//p = 14 // Period used in indicator
//k = 3 // K% setting for stochastic
//d = 9 // Period used for signal line
//RSIndex = 1 // Select RSI
//Stoch = 0 // Select Stochastic
//WilliamsR = 0 // Select Williams%R
//ADXindex = 0 // Select ADX
//SignalLine = 1 // Turn on/off display of signal line
//StartDate = 19950101 // Date to start analysis from. Zero = all data
p = max(1,p)
k = max(1,k)
d = max(1,d)
if date >= startdate then
once signal = undefined
if RSIndex or (not Stoch and not WilliamsR and not ADXindex) then
indicator = rsi[p]
endif
if Stoch then
indicator = stochastic[p,k]
endif
if WilliamsR then
indicator = williams[p]+100
endif
if ADXindex then
indicator = ADX[p]
endif
if signalline then
signal = average[d](indicator)
endif
rindicator = round(indicator)
for a = 1 to 100
if rindicator = a then
$perc[a] = $perc[a]+1
maxval = max(maxval,$perc[a])
break
endif
next
if islastbarupdate then
for a = 1 to 100
thisperc = round(($perc[a]/maxval)*100)
if rindicator = a then
drawpoint(barindex+thisperc+5,a,3) coloured(0,0,255)
drawtext(“#thisperc#%”,barindex+115,a,sansserif,bold,14) coloured(0,0,128)
endif
r = 255
g = 0
if thisperc >= 25 then
r = 128
g = 0
endif
if thisperc >= 50 then
r = 0
g = 255
endif
if thisperc >= 75 then
r = 0
g = 128
endif
drawrectangle(barindex+5,a,barindex+thisperc+5,a) coloured(r,g,128)
next
for a = 1 to 4
if ADXindex then
drawtext(“ADX #p# = #rindicator#”,barindex+5,108,sansserif,bold,14) coloured(0,0,128)
break
endif
if WilliamsR then
drawtext(“Williams%R #p# = #rindicator#”,barindex+5,108,sansserif,bold,14) coloured(0,0,128)
break
endif
if Stoch then
drawtext(“Stochastic #p##k##d# = #rindicator#”,barindex+5,108,sansserif,bold,14) coloured(0,0,128)
break
endif
if RSIndex or (not Stoch and not WilliamsR and not ADXindex) then
drawtext(“RSI #p# = #rindicator#”,barindex+5,108,sansserif,bold,14) coloured(0,0,128)
break
endif
next
endif
endif
return 0 coloured(0,0,0,0) as “Line”,108 coloured(0,0,0,0) as “Line”,indicator as “Indicator”,signal style(dottedline) as “Signal”