As an individual who does not like lower indicators, or charts with too much activity, I like my BestTradingChartSetup with some easily visible upper labels indicating possible changes taking place. Merry Day lists Stochastics as number five on her list of indicators and so I have put together the following STOCHASTIC LABEL to let me know Overbought/Oversold conditions.
The code follows:
The code follows:
Ruby:
#Thanks to RG (?) for basic indicator outline
#Revamped by C. Ricks to show as upper label only
#Note: Label will show Yellow in mid zone and say "Stochastic" - Then Label will turn RED if Stochastic Overbought and Green if Stochastic Oversold
input KPeriod = 14;
input DPeriod = 3;
input price = close;
def lowestLow = Lowest(low, KPeriod);
def highestHigh = Highest(high, KPeriod);
def FastK = if highestHigh != lowestLow then (close - lowestLow) / (highestHigh - lowestLow) * 100 else 0;
def SlowK = Average(FastK, DPeriod);
def SlowD = Average(SlowK, DPeriod);
def overbought = SlowK > 80;
def oversold = SlowK < 20;
AddLabel(yes, "Stochastics" + "" +
if overbought then " (Over Bought) " else if oversold then " (Over Sold) " else "",
if overbought then Color.RED else if oversold then Color.GREEN else Color.Yellow);
#End Code
Last edited by a moderator: