input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input slowing_period = 3;
input averageType = AverageType.SIMPLE;
def stoch = StochasticFull(over_bought = over_bought, over_sold = over_sold, KPeriod = KPeriod, slowing_period = slowing_period, averageType = averageType).FullK;
def StoK = reference StochasticFull.FullK;
def StoD = reference StochasticFull.FullD;
DefineGlobalColor("pretrend", CreateColor(50, 200, 255)) ;
DefineGlobalColor("TrendBEGIN", CreateColor(0, 0, 255)) ;
DefineGlobalColor("rising", CreateColor(0, 165, 0)) ;
DefineGlobalColor("TrendEnd", CreateColor(255, 204, 0)) ;
DefineGlobalColor("maxxed", CreateColor(255, 139 ,61)) ;
DefineGlobalColor("falling", CreateColor(225, 0, 0)) ;
DefineGlobalColor("neutral", CreateColor(204, 204, 204)) ;
AddLabel(yes,
if StoK < over_sold and StoK crosses above StoD then "Stoch Buy" else
if StoK > over_bought and StoK crosses below StoD then "Stoch Sell" else
if Stoch < over_sold then "Stoch pre-trend " +round(Stoch,0) else
if Stoch > over_bought then "Stoch maxxed " +round(Stoch,0) else
if Stoch crosses above over_sold then "Stoch TREND BEGIN!" else
if Stoch crosses below over_bought then "Stoch TREND END!" else
if Stoch >= Stoch[1] then "👍 " + Round(Stoch, 0) else
if Stoch < Stoch[1] then "👎 " + Round(Stoch, 0) else
"Stoch Neutral " +round(Stoch,0),
if StoK < over_sold and StoK crosses above StoD then color.cyan else
if StoK > over_bought and StoK crosses below StoD then color.magenta else
if Stoch < over_sold then GlobalColor("pretrend") else
if Stoch > over_bought then GlobalColor("maxxed") else
if Stoch crosses above over_sold then GlobalColor("TrendBEGIN") else
if Stoch crosses below over_bought then GlobalColor("TrendEND") else
if Stoch > Stoch[1] and Stoch>40 then color.Dark_green else
if Stoch < Stoch[1] and Stoch<40 then color.Dark_red else
if Stoch > Stoch[1] then GlobalColor("rising") else
if Stoch > Stoch[1] then GlobalColor("falling")
else GlobalColor("neutral")) ;