How to set the sound ALERT to trigger with new ORDER and not each BAR?

rottentrade

Member
Like the title says, I would like to hear a sound alert only when new trades are made. Right now, I'm hearing "ding, dong, ding, dong" on every bar. It's driving me up the wall.

Here's what I have in my formula but it's not working:

Code:
##### ALERTS #####

Alert(Buy1, "Buy1", Alert.Bar, Sound.Chimes); ## Shouldn't this work only when the "Buy1" condition kicks in?
Alert(Sell1, "Sell1", Alert.Bar, Sound.Chimes);
Alert(Buy2, "Buy2", Alert.Bar, Sound.Chimes);
Alert(Sell2, "Sell2", Alert.Bar, Sound.Chimes);
 
Last edited:
Solution
@rottentrade It's because the logic carries the same signal over to each successive bar until the signal changes. You have to identify the signal change state, not just the signal.
Try:
Ruby:
##### ALERTS #####

Alert(!Buy1[1] and Buy1, "Buy1", Alert.Bar, Sound.Chimes); ## Shouldn't this work only when the "Buy1" condition kicks in?
Alert(!Sell1[1] and Sell1, "Sell1", Alert.Bar, Sound.Chimes);
Alert(!Buy2[1] and Buy2, "Buy2", Alert.Bar, Sound.Chimes);
Alert(!Sell2[1] and Sell2, "Sell2", Alert.Bar, Sound.Chimes);
@rottentrade It's because the logic carries the same signal over to each successive bar until the signal changes. You have to identify the signal change state, not just the signal.
Try:
Ruby:
##### ALERTS #####

Alert(!Buy1[1] and Buy1, "Buy1", Alert.Bar, Sound.Chimes); ## Shouldn't this work only when the "Buy1" condition kicks in?
Alert(!Sell1[1] and Sell1, "Sell1", Alert.Bar, Sound.Chimes);
Alert(!Buy2[1] and Buy2, "Buy2", Alert.Bar, Sound.Chimes);
Alert(!Sell2[1] and Sell2, "Sell2", Alert.Bar, Sound.Chimes);
 
Solution
Okay that makes sense.

Another question. You say "the logic carries the same signal over to each successive bar until the signal changes" so could I technically use this same logic for other conditions beside "Alert"? For instance,

def reverse = if Buy1 and close < close[1] then Sell;
## Does this mean that once the Buy1 signal is generated it will remain in that position until "close < close[1]"? If not, how would this be coded?

Thanks for your help.
 
I would have to see your complete code for context.
It depends upon your definitions of Buy1, Buy2, Sell1, Sell2.
Your original question made it clear you have Buy1 = Buy1[1], Buy2 = Buy2[1], Sell1 = Sell1[1], and Sell2 = Sell2[1] somewhere in your definitions.
That is what was carrying the signal forward to each following bar.
 

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
284 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