Sound alert help

evolernet

New member
Good afternoon everyone
help to add a sound notification when arrows appear on the chart.
thanks in advance

# TD Ameritrade IP Company, Inc. (c) 2013-2015 гг.
#

entry priceH = high;
entry price L = low;
input percentage Reversal = 5.0;
input absolute reversal = 0.0;
enter atrLength = 5;
input atrReversal = 1.5;

def zigZag = link ZigZagHighLow(priceH, priceL, reversal percentage, absolute reversal, atrLength, atrReversal).ZZ;

def step1 = open[1] >= open и open >= close[1] and open[1] > close[1];
def step2 = open[1] <= open и 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 и close < close[1];
def downStep2 = step2 and close < open[1];

graph 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);
DownStep.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
DownStep.SetDefaultColor(GetColor(1));
DownStep.SetLineWeight(2);
 
# @ evolernet
# your code had a little bit of syntax challenges off so I modified it a little bit for you and added Alerts. Untested but it appears as if it will work better on the aggregations of day or higher

# TD Ameritrade IP Company, Inc. (c) 2013-2015 гг.
#

def entryPriceH = high;
def entryPriceL = low;
input percentageReversal = 5.0;
input absoluteReversal = 0.0;
input atrLength = 5;
input atrReversal = 1.5;

def zigZag = Reference ZigZagHighLow(entryPriceH, entryPriceL, percentageReversal, absoluteReversal, atrLength, atrReversal).ZZ;

def step1 = open[1] >= open or open >= close[1] and open[1] > close[1];
def step2 = open[1] <= open or 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 or 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;

Alert( UpStep, "UpArrow/golong "+round(close,2), Alert.Bar, Sound.Bell) ;
Alert( DownStep, "DnArrow/goShort "+round(close,2), Alert.Bar, Sound.Ding) ;

UpStep.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
UpStep.SetDefaultColor(GetColor(0));
UpStep.SetLineWeight(2);
DownStep.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
DownStep.SetDefaultColor(GetColor(1));
DownStep.SetLineWeight(2);
 
The above code waits until a future bar[-1] and then goes back and paints the signal on the previous bar.
I have not seen an alert that could fire on the repainting of a previous bar.
Alerts 'generally' work on the current bar.

The above code waits until a future bar[-1] and then goes back and paints the signal on the previous bar.

The code I'm using below does not look into the future but does not generate an alert

Ruby:
def upIndicator = vClose < test;
plot upIndicatorp = if upIndicator then open[-1] else nan;
upIndicatorp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
upIndicatorp.AssignValueColor(Color.GREEN);
upIndicatorp.SetLineWeight(1);
Alert(upIndicator, "Sell Signal", Alert.TICK, sound.Bell);
 
The code I'm using below does not look into the future but does not generate an alert
def upIndicator = vClose < test;
plot upIndicatorp = if upIndicator then open[-1] else nan;
upIndicatorp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
upIndicatorp.AssignValueColor(Color.GREEN);
upIndicatorp.SetLineWeight(1);
Alert(upIndicator, "Sell Signal", Alert.TICK, sound.Bell);

On the ToS platform, a negative number in a bracket, refers to that many numbers of bars into the future.
Your code states after the signal happened, wait until the open of the next candle to plot the arrow.
This is not a bad idea. It prevents alerts from occurring during the formation of the candle.

Here is an idea:
Alert(upIndicator within 2 bars, "Sell Signal", Alert.TICK, sound.Bell);
This should get an alert back to the previous bar.
 
Last edited:
My two cents. You may need to add:
input SoundAlerts = Yes;
or
input alertsOn = yes;

Also this example:

From Ken Hahn
Alert(CondA and CondB[2] == 1, "helpful text", Alert.BAR, Sound.Ding);
or
From TOS Indicators
Alert(alertsOn and Cond[1], "helpful text", Alert.ONCE, sound.ring);

Study setting should look like these:

Some of this should be helpful.
KevinCounts
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
446 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