Adding an Alert to Strategy "AddOrder" - ToS

JMW

New member
VIP
I've been playing around a bit with strategies in ToS and I was hoping this was a rather easy question. Along with printing on the chart, I'd like to add an audio alert to when it's printed, as well.

Based off the following AddOrder code, is there somewhere in this syntax I could add the alert option?

Code:
AddOrder(OrderType.SELL, trading_time and (exit) and (exitconditions()) , tickcolor = Color.WHITE, arrowcolor = Color.WHITE, name = "SELL POINT ENTRY");

I have a different line to "Alert(" under the same conditions, but its rather messy and doesn't seem to be working on close conditions - only entries.

Any help would be greatly appreciated, thank you!
 
but its rather messy and doesn't seem to be working on close conditions - only entries

So it worked but not as expected? Can you clarify?

The easiest method would be to use the same condition in the Alert() function, which you did.
 

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

I think the issue being that I might have an open stragety order (BUT_TO_OPEN) triggered, but that then triggers again. The painting on the chart only paints a single open, as it might have opened a few bars back but the alerts keep firing off.

My issue is the alerts constantly triggering when the price is bouncing around a range.
 
I've been playing around a bit with strategies in ToS and I was hoping this was a rather easy question. Along with printing on the chart, I'd like to add an audio alert to when it's printed, as well.

Based off the following AddOrder code, is there somewhere in this syntax I could add the alert option?

Code:
AddOrder(OrderType.SELL, trading_time and (exit) and (exitconditions()) , tickcolor = Color.WHITE, arrowcolor = Color.WHITE, name = "SELL POINT ENTRY");

I have a different line to "Alert(" under the same conditions, but its rather messy and doesn't seem to be working on close conditions - only entries.

Any help would be greatly appreciated, thank you!

have to use alert function to have alerts. they aren't in any other function.

if using the same formula more than once, set it to a variable.

def long_open = trading_time and (exit) and (exitconditions()) ;

AddOrder(OrderType.SELL, long_open,...

alert(long_open, ....

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Others/Alert
 
I think the issue being that I might have an open stragety order (BUT_TO_OPEN) triggered, but that then triggers again. The painting on the chart only paints a single open, as it might have opened a few bars back but the alerts keep firing off.

My issue is the alerts constantly triggering when the price is bouncing around a range.

you need to create another variable , that is true during a trade, call it long.

something like this....

long = if sell then 0 # reset
else if long[1] then 1 # keep true
else if buy then 1 # trigger
else long[1] # hold

then another variable that looks for long to go from false to true, and use that as a buy trigger. then it will only trigger the first time.

buy1 = !long[1] and long;
 
  • Like
Reactions: JMW
Thank you very much! I will give this a thought, I'm a bit dense when it comes to ThinkScript code, but I believe I understand what you're getting at.

Much appreciated it.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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