• Happy Independence Day! Take $40 off VIP Membership with code JULY4. Sign up here.

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.
 

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
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.
 

Bentley

New member
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:
 

pga0008

Member
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
 

Infb11

New member
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?
 

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
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.
 

optiwatch

New member
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.
 
Top