Can we scan for price of 2 years ago?

I'm looking for stocks to test against, and I'd like to be able to run a scan for stocks with price between $15 and $300 two years ago. I have tried:

close[506] >= 15 and close[506] <= 300


close from 506 bars ago is greater than or equal to 15 and close from 506 bars ago is less than or equal to 300

with aggregation set to daily, but in both cases it says there are no matching stocks. Is there a way to do this?
It stopped scanning at 24 months back, so you might have to settle for 23 months back. Be sure to set to the MONTHLY aggregation

def price_2_years_ago = (close(period = AggregationPeriod.MONTH)[23]);
plot scan = price_2_years_ago > 15 and price_2_years_ago < 300;

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

Thanks, @XeoNoX. Carrying on the testing, I've determined that you can go back 503 days, but no more; I was reaching just 3 days beyond the limit.

Also, if a criterion refers to bars prior to that (such as checking a 50 day MA), you need to adjust even more, so you can scan for a 50 day SMA no more than 453 days back.

Restrictive, but it is what it is - I'll tweak my criteria accordingly.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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