Scan intraday within specified timeframe today from start

RuleOneTrading

New member
I've spent hours trying different codes and can't seem to write a simple code where the price does not cross the 150 SMA today.

I'm not sure how to have it scan for only today when using the 2m aggregation period or how to tell it to remove any stocks that have crossed the 150 SMA today.

I created a criteria scanning for any crossing in the last 390 minutes and setting that under the 'None of the following' but can't find a way to have it scan from open rather than the last 390 minutes, which includes yesterday.

I'm scanning for this criteria because I use a scanner for stocks that are trending. HH and HL ranges have proven inconsistent and using trend indicators only let's me know if a stock is trending at the moment, which continues to show stocks that have been massively choppy all day. A stock that has been above the 150 SMA and never crossed won't be as choppy.
 
Solution
Ruby:
def Cross = Low < SimpleMovingAvg(close,150);
#def Cross = Crosses(Close,SimpleMovingAvg(close,150),crossingDirection.ANY);
def NewDay = GetTime() == RegularTradingStart(GetYYYYMMDD()) + 1;
def Today = GetDay() == GetLastDay();
def Check =
    if NewDay and Cross then Yes
    else if NewDay and !Cross then No
    else if Check[1] then Check[1]
    else if Cross then yes
    else no
;
plot Scan = Today and !Check;
Ruby:
def Cross = Low < SimpleMovingAvg(close,150);
#def Cross = Crosses(Close,SimpleMovingAvg(close,150),crossingDirection.ANY);
def NewDay = GetTime() == RegularTradingStart(GetYYYYMMDD()) + 1;
def Today = GetDay() == GetLastDay();
def Check =
    if NewDay and Cross then Yes
    else if NewDay and !Cross then No
    else if Check[1] then Check[1]
    else if Cross then yes
    else no
;
plot Scan = Today and !Check;
 
Solution

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