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