How to add an alert in TOS' ZigZag Pattern?

oswald57

New member
VIP
Hi,

ThinkOrSwim has a candlestick pattern called ZigZagStepPattern. It would be nice to have sound alerts. I copied the source of this and created a study of it. Then I added lines for the alerts but they do not execute. I have also added vertical lines and they show up on the chart just fine.

Does anyone know why sound alerts don't work (for me)?

Thank you.

Jim

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2013-2020
#
# Added alerts (if they work)

input priceH = high;
input priceL = low;
input percentageReversal = 5.0;
input absoluteReversal = 0.0;
input atrLength = 5;
input atrReversal = 1.5;

def zigZag = reference ZigZagHighLow(priceH, priceL, percentageReversal, absoluteReversal, atrLength, atrReversal).ZZ;

def step1 = open[1] >= open and open >= close[1] and open[1] > close[1];
def step2 = open[1] <= open and open <= close[1] and open[1] < close[1];

def upStep1 = step1 and close > open[1];
def upStep2 = step2 and close > close[1];
def downStep1 = step1 and close < close[1];
def downStep2 = step2 and close < open[1];

plot UpStep = (upStep1 or upStep1[-1] or upStep2 or upStep2[-1]) and zigZag == low;
plot DownStep = (downStep1 or downStep1[-1] or downStep2 or downStep2[-1]) and zigZag == high;

UpStep.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
UpStep.SetDefaultColor(GetColor(0));
UpStep.SetLineWeight(2);
Alert(UpStep, "ZigZag Long", Alert.BAR, Sound.Ding);
AddVerticalLine (UpStep, "                                            ZigZag Long", Color.GREEN);
AddLabel(UpStep, "ZigZag Long", Color.GREEN);


DownStep.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
DownStep.SetDefaultColor(GetColor(1));
DownStep.SetLineWeight(2);
Alert(DownStep, "ZigZag Short", Alert.BAR, Sound.Ding);
AddVerticalLine (DownStep, "                                         ZigZag Short", Color.RED);
AddLabel(DownStep, "ZigZag Short", Color.RED);
 

BenTen

Administrative
Staff
VIP
Add the following to the bottom of your script:

Code:
# Alerts
Alert(UpStep, " ", Alert.Bar, Sound.Chimes);
Alert(DownStep, " ", Alert.Bar, Sound.Bell);

Important to note that this ZigZag pattern is a repainting indicator. Signals are going to be delayed and disappear (if it's wrong).
 

oswald57

New member
VIP
Hi BenTen,

Thanks for the input.

Are you saying that the alert lines need to be at the bottom in order to work? Because I have those lines in the script already, just not at the bottom.
 

BenTen

Administrative
Staff
VIP
@oswald57 Oops, I did not see that. No, they do not have to be at the bottom of the code to work.

In this case, the repainting and delaying factors are affecting the alert. The alert code will not work for this particular study.
 

Similar threads

Top