How to add an alert in TOS' Zig Zag Pattern?

oswald57

New member
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);
 
Solution
@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.
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).
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

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.
 
@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.
 
Solution
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);
I used this script. I tried on few stocks (5 min. chart). Only displays the 'ZigZag Short'. I don't see it displays the 'ZigZag Long'. Is there any issue with this script? Can we use this script for intraday alerts?
 
I used this script. I tried on few stocks (5 min. chart). Only displays the 'ZigZag Short'. I don't see it displays the 'ZigZag Long'. Is there any issue with this script? Can we use this script for intraday alerts?
My bad. If I display 30 days on 5 min. chart, I see long and short signals. Can I use this script for intra day long and short signals (5 min. chart)?
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
214 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top