Koolkth1
New member
Many years ago I developed a Stochastic Divergence Indicator, (code below and photos below), works best on 5 min time frame and up. I made this from a lot of cutting and pasting/trial and error. Basically when a Divergence is detected a the indicator produces a spike in the lower study section. The photos show where these divergences are, please note, I drews these lines, not the indicator.
Here's the photo of how it works:
Stochastic Divergence Code:
Here's the photo of how it works:
Stochastic Divergence Code:
Ruby:
input over_bought = 80;
input over_sold = 20;
input KPeriod = 14;
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On FullK", "On FullD", "On FullK & FullD"};
def lowest_k = Lowest(priceL, KPeriod);
def c1 = pricel - lowest_k;
def c2 = Highest(priceH, KPeriod) - lowest_k;
def FastK = if c2 != 0 then c1 / c2 * 100 else 0;
def FullK = MovingAverage(averageType, FastK);
def FullD = MovingAverage(averageType, FullK, DPeriod);
def upK = FullK crosses above Over_sold;
def upD = FullD crosses above Over_sold;
def downK = FullK crosses below Over_bought;
def downD = FullD crosses below Over_bought;
plot data = (upd)or (upk);
Last edited by a moderator: