Opening Range Breakout Stock Scan TOS


Category:
0
0

I noticed there have been a few questions and answers about how to scan for opening range breakouts by a certain time of the day in Think or Swim.  Individuals have asked for 5 minute scans, over night gaps and pre market high/lows.  There was even a case where someone linked another sites scan and Pete kindly reposted it with edits.

In an effort to centralize all the answers, referred upon scans videos,  and pages I am asking:

Can you post scan inputs(not chart signals) on how to look for stocks breaking their 10:30 am high/low?

Theoretically this scan should yield no results until after 10:30 am as it would be looking for breaks of the first 60 minutes high/low.

Thank you in advance

 

 

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on July 6, 2018 8:25 pm
2418 views
0
Private answer

The simplest solution to this request is to write the code specifically to fit this one scenario. Which means the code will be set to take the opening range from the first two 30 min bars. The scan itself will be set to the 30 min time frame. Any other time frame will result in the opening range being set to the first two bars of whatever time frame you change it to.

Here is the code.

def newDay = GetDay() <> GetDay()[1];
rec orHigh = if newDay[1] then Max(high, high[1]) else orHigh[1];
rec orLow = if newDay[1] then Min(low, low[1]) else orLow[1];
def orBreakHigh = !newDay and !newDay[1] and high > orHigh and high[1] <= orHigh;
def orBreakLow = !newDay and !newDay[1] and low < orLow and low[1] >= orLow;
plot scan = orBreakHigh;
#plot scan = orBreakLow;

So that is strictly built for a scan. The last two lines will be the conditions you are scanning for. Only one can be turned on at a time.

I try to take the time to plot these while I’m writing them. This helps me to visualize what the code is doing. And I often catch errors and unexpected behavior when I do so. Since I took the time to do that I wanted to include a screenshot.

This is a three chart grid, showing three different time frames, 30 min, 15 min and 5 min. Only the 30 min time frame sets the opening range at the close of the 10:30 am bar. Keep in mind this code not care what TimeZone your charts are set to. However mine are always set to Eastern TimeZone. (which is exactly what TimeZone the scan engine runs on!)

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on July 7, 2018 7:16 am
0

thanks a lot for the detailed answer. I learned much about it from you

( at July 8, 2018 11:19 am)
0
Pete, What would need to be changed in this code to have it work on 1 min candles. If 10:30 am is still the activation time. There would be 60- 1 min candles from market open. That would void the "first 2 candles" that you referenced. Is there a way to make it use the first 60 / 1 min candles as its reference point?
( at October 13, 2019 3:26 pm)
0
Unless you are adding something else to this, there is absolutely no reason to run this scan on a 1 min time frame. The price crossing an opening range is not dependent on a time frame. Run the scan on a 30 min time frame and you will get results as soon as the price crosses either level. Going down to 1 min time frame will only serve to limit your scan results to stocks that have crossed within the last 59 seconds. Using a 1 min time frame, if you are not hitting that scan button every 60 seconds you are missing the vast majority of signals. Personally I find a lot of folks trying to use 1 min time frames for watchlists and scans but they don't fully understand the impact. They think the 1 min time is giving them faster results but in reality it is causing them to miss almost everything.
( at October 13, 2019 3:49 pm)
0
Ok, so even though I trade on the 1 min. the scan doesn't matter if it is set to a 30 min scan. Is that a fair assumption?
( at October 13, 2019 5:17 pm)
0
Yes. If all you need is a scan that finds stocks breaking the first hour opening range. You can set the scan to 30 min time frame and it will find those stocks. You will run the scan once every 30 minutes after the first hour. Or you can run it every minute if you need to get more frequent notifications.
( at October 13, 2019 6:11 pm)