# 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:
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!

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.

High/Low Order Signals for Futures Questions 3
False Signals Questions 2
MTF Marubozu signals Questions 0
Time Duration between Signals Questions 1
Remove Duplicate Signals Questions 1

87k+ Posts
225 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?