52 week high occuring Intraday


Category:
0
0

Hi Pete,

Please guide me to a scan for a 52 week high occuring intraday. This scan should show securities whose 52 week high was exceeded intraday.

Thank you

Marked as spam
Posted by (Questions: 1, Answers: 2)
Asked on June 14, 2021 9:38 pm
136 views
0
Private answer

It is not possible to write code for a Study Filter of a scan that can read the 52 week high from an intraday time frame. We can approximate this value but we cannot get it to exactly match the value you would compute from a weekly time frame.

FYI, if you set a Study Filter to a weekly time frame and apply the following code it will trigger intraday if and when the price crosses above that previous 52 week high:

plot scan = close > Highest(high[1], 52);

I don't understand why anyone would need to use an intraday time frame to get an alert for stocks crossing the 52 week high. When it's pretty obvious that you get the most accurate results by using the weekly time frame and you also get results throughout the current trading session. If the stock breaches that 52 high at 10:17 am on Monday, the weekly time frame scan will pick that up Monday at 10:17 am. If it breaches the 52 high at 2:36 pm on Thursday then the scan will pick that up Thursday at 2:36 pm

For some reason many users of Thinkorswim believe that by using a lower time frame their scans will return faster results. This is not true and I explain why in the following video:

https://www.hahn-tech.com/thinkorswim-scans-beginner-to-advanced/

The only intraday time frame that is able to get close to matching the accuracy of the scan I just described is the 1 hour, 2 hour or 4 hour time frames.Why? Because there are limitations to how much historical data is available to Study Filters of a custom scan. Details here:

https://toslc.thinkorswim.com/center/howToTos/thinkManual/Scan/Stock-Hacker/studyfilters

Note this approach is NOT as accurate as using the weekly time frame. But since you requested a solution for the intraday time frame I will provide that. But you must understand it is not as accurate and requires that you compute how many hourly bars are in a 52 week period.

The first problem you run into is you have no way to compute how many holidays were withing that 52 week period. And you will never be able to include extended hours trade data in this scan because for the vast majority of stocks the number of bars during extended hours session changes from day to day.

So lets take the example of a 1 hour time frame and compute an approximate value for the number of bars in a 52 week period. We know that without holidays there are 5 trading days in each week. 52 times 5 gives us 260 days. We can look at any 1 hour chart and count the number of bars in each regular session, which is 7. Now we multiply the number of trading days in 52 weeks and multiply that by 7, giving us a final value of 364. That's 364 hourly bars to approximate a period of 52 weeks. Close, but not exactly 52 weeks.

After performing that computation we can derive a scan that works on a 1 hour time frame and comes close to a true 52 week high:

plot scan = close > Highest(high[1], 364);

Looks exactly like the weekly scan doesn't it? The only difference is the number of bars used to find the target high. But this is not going to be as accurate as using the first scan and setting the Study Filter to a weekly time frame.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on June 15, 2021 7:34 am
0
Thank you for taking the time for a detailed reply. It helps a broader understanding for me. 1 hour timeframe will work perfectly for me. If I understand correctly, a security, which meets the scan criteria, will be selected as a result for up to one hour for 1 hour time frame; up to four hours for a 4 hour time frame, etc.
( at June 15, 2021 2:55 pm)
0
The scan is set to trigger when the current price of any candle exceeds the highest high in the last x number of bars. So for a 1 hour time frame and n = 364, the scan will pick up any stock where the current 1 hour candle trades above the highest high in the last 364 1 hour bars. If price trades back below that highest high in 364 bars the stock will no long appear in the scan results. The scan is based on current price. The time frame selected has no impact on this. There is no such thing as "...selected as a result for up to one hour..."
( at June 15, 2021 4:40 pm)