![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHaoZZNhLOWKFwGxZeMj7a0iM2yF_a90pZja2ntOzjhr4flZUq3l3j1-LyR23NpjOgmj97mJJzgB-VHR3a_uEPi7r6_b5grs7e-LMR8BAwQOxzgHCEEIv1YdZEGSgudTMmHWXUxn2Yi72e/s400/Beach_Laptop.jpg)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzxmBMFtAZwoa6OJfNU0KT3ri68qbuWnSwjxcVxBo-9PDspPj5wXw0ctcOBA-TEwozQiz484HyVOEwjDYtoiBHULmE9ZQJPCdvijf_I7QL68oy3YqTKGS6_FZCJe2GHIjxboOA2hshlHKe/s400/PercentR_SMA.jpg)
The Williams%R indicator is famous for the -20 and -80 % levels to indicate overbought and oversold conditions. Watch for the 2 lines to cross on the -20 and -80 centerlines for your potential signals.
Enjoy the Free code.
declare lower;
input Length = 14;
input OverBought = -20;
input OverSold = -80;
input MovAvgLength = 9;
def highest = Highest(high, Length);
def lowest = Lowest(low, Length);
def data = if highest == lowest then -100 else (highest - close) / (highest - lowest) * (-100);
plot PercentR_SMA = if( data > 0, 0, data);
PercentR_SMA.SetDefaultColor(Color.BLUE);
plot Over_Sold = overSold;
Over_Sold.SetDefaultColor(GetColor(8));
plot Over_Bought = overBought;
Over_Bought.SetDefaultColor(GetColor(8));
plot SMA = Average(data =PercentR_SMA, length = MovAvgLength);
SMA.SetDefaultColor(GetColor(5));