#Plot previous week's high / low
plot Yhigh = high(period = "week" )[1];
plot Ylow = low(period = "week" )[1];
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
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 closeUse 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?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.
Unfortunately it is not possible to fulfill your request. Thinkscript syntax works with mathematical equations. There is no mathematical definition for 'approaching'Ben, is there a way to scan for price approaching these levels?
Thanks for posting this. I was trying to figure out how to get around the "Secondary period not allowed" error for scans.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.
close() > high[1]
" # 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
"
Start a new thread and receive assistance from our community.
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.
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.