This script uses three lengths of Williams %R , calculates a bunch of averages and distances, highs and lows to determine pivots points. Lengths are currently optimised for 30m GER30 .
study(title="Williams %R III Pivots", shorttitle="%RIIIP") // Williams %R slow length1 = input(48, minval=1) upper1 = highest(length1) lower1 = lowest(length1) out1 = 100 * (close - upper1) / (upper1 - lower1) + 100 // Williams %R medium length2 = input(240, minval=1) upper2 = highest(length2) lower2 = lowest(length2) out2 = 100 * (close - upper2) / (upper2 - lower2) + 100 // Williams %R slow length3 = input(960, minval=1) upper3 = highest(length3) lower3 = lowest(length3) out3 = 100 * (close - upper3) / (upper3 - lower3) + 100 avg_out = (out1+out2+out3)/3 avg_dist=(abs(out1-out2)+abs(out1-out3)+abs(out2-out3))/3 sma_dist=sma(avg_dist,14) sma_out=sma(avg_out,14) act=abs(sma_out-sma_dist) pivot_length=30 upBound = highest(act, pivot_length) downBound = lowest(act, pivot_length) plot(sma_dist, color=#00FF00, linewidth=2) plot(sma_out, color=#FF0000, linewidth=2) plot(act, color=black, linewidth=2) plot((upBound == act[1] and upBound != act and abs(act-sma_out)<20 and act > 60) ? act : na, style = cross, linewidth = 2, color=#FF0000) plot((downBound == act[1] and downBound != act and act < sma_dist and act < 15) ? act : na, style = cross, linewidth = 2, color=#00FF00)