I didn't check your logic. I just added the arrow statements.Need some help.
im trying to create an alert for two conditions in the Slow Stoch.
I. when slow K is above 80, and then crosses below slow D - want a down arrow and an audible alert
II. when slow K is less than 20 and then crosses above slow D - want an up arrow and audible alert
(no alerts if there are crosses when K is between 80-20)
See my attempt below.
I've created "signal" which accomplishes "I." and "signal two" which accomplishes II. -- but i cant seem to get the arrows to work.
All of my attempts end up putting arrows corresponding with every single candle as opposed to just when the crossover occurs
can anyone help?
Ruby:
declare lower;
input over_bought = 80;
input over_sold = 20;
input KPeriod = 8;
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On SlowK", "On SlowD", "On SlowK & SlowD"};
plot SlowK = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,priceH,priceL,priceC,3,averageType).FullK;
plot SlowD = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,priceH,priceL,priceC,3,averageType).FullD;
plot OverBought = over_bought;
plot OverSold = over_sold;
def slowKOverbought = slowK[1] > 80;
def slowKCrossesBelowSlowD = slowK[1] > slowD[1] and slowK < slowD;
plot signal = if slowKOverbought and slowKCrossesBelowSlowD then SlowK else double.NaN;
signal.SetPaintingStrategy(PaintingStrategy.ARROW_down);
signal.SetDefaultColor(color.magenta) ;
signal.SetLineWeight(1);
Alert(signal, "SlowK and SlowD Crossing: OverBought", Alert.BAR, Sound.RING);
def slowKOverSold = slowK[1] < 20;
def slowKCrossesAboveFullD = slowK[1] < slowD[1] and slowK > slowD;
plot signaltwo = if slowKOverSold and slowKCrossesAboveFullD then SlowK else double.NaN;;
signaltwo.SetPaintingStrategy(PaintingStrategy.ARROW_up);
signaltwo.SetDefaultColor(color.blue) ;
signaltwo.SetLineWeight(1);
Alert(signaltwo, "SlowK and SlowD Crossing: OverSold", Alert.BAR, Sound.RING);