```
# TD Ameritrade IP Company, Inc. (c) 2008-2020
# Rewrite for Tradingview "Pine Script" by Kocurekc, April 2014
# mods for TOS by WTF_Dude
declare lower;
input KPeriod = 14;
input DPeriod = 5;
input J_smoothPeriod = 7;
input AverageType = AverageType.EXPONENTIAL;
input Smooth_J = no;
input J_Average = AverageType.SIMPLE;
input priceH = high;
input priceL = low;
input priceC = close;
input over_bought = 80;
input over_sold = 20;
#input showBreakoutSignals = {default "No", "On SlowK", "On SlowD", "On SlowK & SlowD"};
plot K = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,priceH,priceL,priceC,3,averageType).FullK;
plot D = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,priceH,priceL,priceC,3,averageType).FullD;
def SLOWJ = (3*k) - (2*d);
plot J;
if SMOOTH_J {
J = MovingAverage(J_average,SLOWJ,J_smoothperiod);
} else {
J = SLOWJ;
}
plot OverBought = over_bought;
plot OverSold = over_sold;
#plot SmoothJ = movingaverage(Averagetype, SLOWJ, 5);
#SmoothJ.SetHiding(!Smooth_J);
def upK = K crosses above OverSold;
def upD = D crosses above OverSold;
def downK = K crosses below OverBought;
def downD = D crosses below OverBought;
#plot UpSignal;
#plot DownSignal;
#switch (showBreakoutSignals) {
#case "No":
# UpSignal = Double.NaN;
# DownSignal = Double.NaN;
#case "On SlowK":
# UpSignal = if upK then OverSold else Double.NaN;
# DownSignal = if downK then OverBought else Double.NaN;
#case "On SlowD":
# UpSignal = if upD then OverSold else Double.NaN;
# DownSignal = if downD then OverBought else Double.NaN;
#case "On SlowK & SlowD":
# UpSignal = if upK or upD then OverSold else Double.NaN;
# DownSignal = if downK or downD then OverBought else Double.NaN;
#}
#UpSignal.setHiding(showBreakoutSignals == showBreakoutSignals."No");
#DownSignal.setHiding(showBreakoutSignals == showBreakoutSignals."No");
K.setDefaultColor(GetColor(1));
D.setDefaultColor(GetColor(0));
J.setDefaultColor(Getcolor(6));
OverBought.SetDefaultColor(GetColor(3));
OverSold.SetDefaultColor(GetColor(3));
#UpSignal.SetDefaultColor(Color.UPTICK);
#UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
#DownSignal.SetDefaultColor(Color.DOWNTICK);
#DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
```