Scan for stocks above previous Week High and previous DAY High

we29125

Member
Scan for stocks above previous Week High and previous DAY High

How do i do it ? My custom scan query either allow DAY or Week. Not both.
 
Use this script:

Code:
#Plot previous week's high / low
plot Yhigh = high(period = "week" )[1];
plot Ylow = low(period = "week" )[1];

In your scanner, create a condition where close is above Yhigh or close is below Ylow.

Then you can also create another condition and change the aggregation period to DAY.
 
Hi everyone,
Was wondering would any kind souls provide some help or direction about finding stock that find the condition as per the title? I call this the matching stock, which are stock that matches in high or low... Basically, like to find stock that are equal in high and low. Say something like... is there any day in the last 90 days, the high is equal to yesterday low... to the nearest 1 decimal point ...

Would be sweet if an arrow indication on the matches dates...

Thanks to all:cool:
 
Use this script:

Code:
#Plot previous week's high / low
plot Yhigh = high(period = "week" )[1];
plot Ylow = low(period = "week" )[1];

In your scanner, create a condition where close is above Yhigh or close is below Ylow.

Then you can also create another condition and change the aggregation period to DAY.
Ben can you share how this looks in the scanner when I do it I’m getting the secondary error. I want to see if today’s close is above last weeks high or last weeks close
 
Use this script:

Code:
#Plot previous week's high / low
plot Yhigh = high(period = "week" )[1];
plot Ylow = low(period = "week" )[1];

In your scanner, create a condition where close is above Yhigh or close is below Ylow.

Then you can also create another condition and change the aggregation period to DAY.
Ben, is there a way to scan for price approaching these levels?
 
Ben, is there a way to scan for price approaching these levels?
Unfortunately it is not possible to fulfill your request. Thinkscript syntax works with mathematical equations. There is no mathematical definition for 'approaching'

Some members use a percentage to determine this. This thread has 8 pages of examples of how to define percentages between two plots:
https://usethinkscript.com/threads/...een-emas-or-any-2-plots-for-thinkorswim.1345/
It should get you started on your quest.
 
Use this script:

Code:
#Plot previous week's high / low
plot Yhigh = high(period = "week" )[1];
plot Ylow = low(period = "week" )[1];

In your scanner, create a condition where close is above Yhigh or close is below Ylow.

Then you can also create another condition and change the aggregation period to DAY.
Thanks for posting this. I was trying to figure out how to get around the "Secondary period not allowed" error for scans.
You suggest that we can use two filters. (one for daily and one for weekly). That had me hopeful, but I think you still can not compare Day to Week aggregation in the second filter/condition.

I started with a coding error for a column where nothing was greater than the other and nothing was less than the other when comparing closing prices. What I realized is that "close" is the same as "latest" price and I was accidentally comparing the current week close to the current day close. These values will always be the same.

I think the answer can be done using weekly aggregation with one filter coded as follows.
Add Filter -> Study -> Custom
Code:
close() > high[1]
The current price is greater than last week's high.

Note: This solution would not work if you wanted to compare the current day's high to last week's high, because secondary aggregation would be needed.

Let me know if I missed something.
 
I found this code from the thinkscript chat lounge and modified based on my needs. See if this works for you

Code:
"  # Use in daily Aggregation
def NewWeek = GetWeek() <> GetWeek()[1];
def WH = if NewWeek then high else if high > WH[1] then high else WH[1];
def PWH = if NewWeek then WH[1] else PWH[1];

plot scan = close>High[1] and close >PWH ;

# End of code

"
 

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