• Get $40 off VIP by signing up for a free account! Sign Up

Possible to condition alerts to only trigger during market hours?

Hey guys, as I have been actively trading while at the same time learning and testing to complete how I want to go about it, I often leave my screens up all day. But hearing the sporadic dings, bells and rings while I'm going about my day or trying to work on other stuff in the foreground, I swear is going to make me develop a nervous tick. Is there a way to condition an alert to only sound off when the market is open? How would I alter, say, an alert like this:

Code:
Alert(cross_above, "RSI LONG", Alert.Bar, Sound.BELL);
 
Solution
Hey guys, as I have been actively trading while at the same time learning and testing to complete how I want to go about it, I often leave my screens up all day. But hearing the sporadic dings, bells and rings while I'm going about my day or trying to work on other stuff in the foreground, I swear is going to make me develop a nervous tick. Is there a way to condition an alert to only sound off when the market is open? How would I alter, say, an alert like this:

Code:
Alert(cross_above, "RSI LONG", Alert.Bar, Sound.BELL);

Adding a true/false (1/0) def of rthrs to the alert should work.

Code:
def rthrs = SecondsFromTime(0930) >= 0 and SecondsFromTime(1600) < 1600;
Alert(rthrs and cross_above, "RSI LONG", Alert.BAR...
Hey guys, as I have been actively trading while at the same time learning and testing to complete how I want to go about it, I often leave my screens up all day. But hearing the sporadic dings, bells and rings while I'm going about my day or trying to work on other stuff in the foreground, I swear is going to make me develop a nervous tick. Is there a way to condition an alert to only sound off when the market is open? How would I alter, say, an alert like this:

Code:
Alert(cross_above, "RSI LONG", Alert.Bar, Sound.BELL);

Adding a true/false (1/0) def of rthrs to the alert should work.

Code:
def rthrs = SecondsFromTime(0930) >= 0 and SecondsFromTime(1600) < 1600;
Alert(rthrs and cross_above, "RSI LONG", Alert.BAR, Sound.Bell);
 
Solution
Adding a true/false (1/0) def of rthrs to the alert should work.
Ran into another similar issue. I've been creating a few of my own candle pattern indicators and the way a candle fluctuates as it's being created causes the alert to trigger on almost every candle in it's first few seconds as it's taking shape. Would it be possible to delay an alert to go off, say, after 1 minute or later has passed on a two minute candle? Basically look for conditions after a certain amt of time?

I'm using that last bit of code you provided ALOT by the way, it's a life-saver!
 
Last edited:
Ran into another similar issue. I've been creating a few of my own candle pattern indicators and the way a candle fluctuates as it's being created causes the alert to trigger on almost every candle in it's first few seconds as it's taking shape. Would it be possible to delay an alert to go off, say, after 1 minute or later has passed on a two minute candle? Basically look for conditions after a certain amt of time?

I'm using that last bit of code you provided ALOT by the way, it's a life-savor!

You can set the alert to trigger after the 2m bar closes. The code below has both the cross at the 2m bar and after it closes. The alert is set to after the 2m bar closes. Bubbles were added so you can visually see the gray bubble when the cross occurs and the yellow when after the previous bar closes, when the alert then sounds.

You could also add some other condition to your cross, such as, close>high[1] to try to confirm the cross before sounding the alert.

We do not have access to smaller timeframes than the chart timeframe, so we could not use a certain amount of time less than 2m in your case.

Screenshot 2024-02-03 081140.png

Code:
def rthrs = SecondsFromTime(0930) >= 0 and SecondsFromTime(1600) < 1600;

plot cross_above  = reference rsi() crosses above 30;
plot cross_above1 = reference rsi()[1] crosses above 30;
addchartBubble(cross_above, low, cross_above + "\n" + cross_above1, color.gray, no);
addchartBubble(cross_above1, low, cross_above + "\n" + cross_above1, color.yellow, no);

Alert(condition = rthrs and cross_above1, text = "RSI LONG", sound = Sound.Bell, "alert type" = Alert.BAR);
 
You can set the alert to trigger after the 2m bar closes. The code below has both the cross at the 2m bar and after it closes. The alert is set to after the 2m bar closes. Bubbles were added so you can visually see the gray bubble when the cross occurs and the yellow when after the previous bar closes, when the alert then sounds.

You could also add some other condition to your cross, such as, close>high[1] to try to confirm the cross before sounding the alert.

We do not have access to smaller timeframes than the chart timeframe, so we could not use a certain amount of time less than 2m in your case.
Thats a good idea adding an additional condition- I didn't think of it before, but I found Mashume's tallCandles code and I think I can change it to trigger when candle is at least 1/2 avg size or something... that might help to keep a lot of these alerts from triggering in the first few seconds of candle formation. Thanks again (y)(y)
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
288 Online
Create Post

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