I've tried many different ways to get alerts to trigger on OSpeakTrigger and OBpeakTrigger but have been unsuccessful. I feel like I must be missing something. Obviously I'm getting the verticals, so obviously the condition is true, but the alert isn't audible. Seems it may have something to do with the parameter SlowK[-1]. Can someone please help me? Is there a fix for this? Thanks!
Code:
declare upper;
#########################################################
# Parameters
input overBought = 75;
input overSold = 25;
input KPeriod = 5;
input DPeriod = 3;
input averageType = AverageType.EXPONENTIAL;
#** Oversold trigger on/off
input useOsPeakTrigger = yes;
#** Overbought triger on/off
input useObPeakTrigger = yes;
#########################################################
# Triggers
def SlowK = reference StochasticFull(overBought, overSold, KPeriod, DPeriod, high, low, close, 3, averageType).FullK;
def OSpeakTrigger = if useOsPeakTrigger and (SlowK <= overSold) and (SlowK < SlowK[-1]) and (SlowK < SlowK[1]) then 1 else 0;
def OBpeakTrigger = if useObPeakTrigger and (slowK >= overBought) and (slowK > slowK[-1]) and (slowK > slowK[1]) then 1 else 0;
#########################################################
# Vertical Lines
AddVerticalLine(OSpeakTrigger, "", Color.Green, Curve.LONG_DASH);
AddVerticalLine(OBpeakTrigger, "", Color.Red, Curve.LONG_DASH);
###################################################################################
# Alert Settings
input useAlert = yes;
input alertType = {default "BAR", "ONCE", "TICK"};
input alertText = "VERT PEAK ALERT!";
input alertSound = {"Bell", "Chimes", "Ding", "NoSound",default "Ring"};
def AT = alertType;
Alert(useAlert and OSpeakTrigger, alertText, if AT == 1 then Alert.ONCE else if AT == 2 then Alert.TICK else Alert.BAR, alertSound);
Alert(useAlert and OBpeakTrigger, alertText, if AT == 1 then Alert.ONCE else if AT == 2 then Alert.TICK else Alert.BAR, alertSound);
###################################################################################
Last edited: