Sticky Signals Using Date and Time

StoneMan

Member
Plus
I'm trying to figure out if what I want here is possible. Any insights are greatly appreciated. What I want is a signal that can tell me if an indicator has exceeded a set value for the current day on an intraday time frame. An example of the type of question the indicator would be answering is, "Did the 5 min RSI get above 70 today?" And the indicator would return a true or false answer. On a deeper level the indicator would be sitting at zero all day until the 5 min rsi gets above 70. At that point it would return a value of 1 and stay there until the day ends regardless of what the RSI does for the rest of the day. How to get this going has me stumped. I was thinking of maybe messing with the clock or date values. For example, if the RSI crosses above 70, the condition is true until the date (say 8/19) timestamped at the cross over no longer equals the date on the chart; the condition would stop being true as soon as the clock turned to 8/20. At that point the indicator would return to zero and the cycle repeats. I'm honestly not even sure if this is possible in Thinkorswim. But if it's doable it could have some pretty big implications with regards to event stickiness when crafting signals. So I'm hoping some of you wizards out there could give me some insights/jumping off point/solutions. Cheers.
 
Solution
Yes, this is possible. I created it as a lower study so you can see clearly what it's doing. You can adapt this code to create a label or watchlist column or whatever else and you can use the same pattern for other conditions such as MACD > 0 or whatever else.

Ruby:
declare lower;

def s =
  if GetDay() != GetDay()[1] then reference RSI > 70
  else if s[1] == 1 then 1 else reference RSI > 70
;

plot signal = s;
Yes, this is possible. I created it as a lower study so you can see clearly what it's doing. You can adapt this code to create a label or watchlist column or whatever else and you can use the same pattern for other conditions such as MACD > 0 or whatever else.

Ruby:
declare lower;

def s =
  if GetDay() != GetDay()[1] then reference RSI > 70
  else if s[1] == 1 then 1 else reference RSI > 70
;

plot signal = s;
 
Last edited:
Solution

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

Thank you Slippage that's exactly what I need. One minor correction for the code is to change signal[1] to s[1] then it works great!
Ah, yeah. Good job fixing that. I originally had signal as the def and then when I added the plot I named it "s". Then I realized that's not a good name to appear in the study's options so I swapped them but I missed updating it on that line. I've updated the code now so it's correct for any others who copy it.
 
Thread starter Similar threads Forum Replies Date
P False Signals Questions 2
V MTF Marubozu signals Questions 0
kevinhng77 Time Duration between Signals Questions 1
rvaidyamath Remove Duplicate Signals Questions 1
Picard Repaints Trend Reversal with Signals Questions 7

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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