# Scanning for a specific bar (4am and 9:30am)

#### AssassinAR15

##### Member
Good afternoon. I have been searching for a way to scan for specific bars.

For example, If I wanted to scan for all relative volume values over 5 at 9:30a on the 5minute timeframe, how would I do that?

I am able to use the "offset" and "Bars" functions, but I am looking for a more specialized scan.

I was able to find this snippet of code below, but I have not been able to get any further. @generic (thank you for all your help)

declare lower;
input startTime = 930;
input endTime = 935;
def startOfScan = SecondsFromTime(startTime) > 0;
def endOfScan = SecondsTillTime(endTime) > 0;
plot scanPeriod = startOfScan or endOfScan;

Solution
@ProfessorAR15 I think this is what you want.
Code:
``````input time = 930;
input length = 60;
input numDev = 5.0;

def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length);
def timer = SecondsFromTime(time) == 0;
def over = if timer then if rawrelVol > numDev then 1 else 0 else over[1];

plot scan = over == 1;``````
@ProfessorAR15 I don't understand the request. Are you looking to scan during the 5 minutes or scan sometime after, ie. 10:00 am, and want to know what stocks had rvol higher than 5 during the first 5 minute. I won't be able to help until tomorrow after market close so I'll check back at that time.

@ProfessorAR15 I don't understand the request. Are you looking to scan during the 5 minutes or scan sometime after, ie. 10:00 am, and want to know what stocks had rvol higher than 5 during the first 5 minute. I won't be able to help until tomorrow after market close so I'll check back at that time.
Thank you, and absolutely no rush.

Going back to the rVOL example........lets say I start trading at 8am, and I have a watchlist of 75 stocks. What I want to know, is which ones had rVOL scores over 5 on the 4am bar, and ONLY the 4am bar. If a stock had a rVOL value of 5 at 4:30am, this scan would not pick it up as it's out of scope.

This can be done using standard settings if I were to do the scan at 4:05am for the last bar, but it's much more difficult do to it during regular trading hours, as the bar would need to be changed every 5 minutes in order to keep the scan at the specific time that I want.

I hope this makes more sense, please let me know if not. Thank you again!

@ProfessorAR15 I think this is what you want.
Code:
``````input time = 930;
input length = 60;
input numDev = 5.0;

def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length);
def timer = SecondsFromTime(time) == 0;
def over = if timer then if rawrelVol > numDev then 1 else 0 else over[1];

plot scan = over == 1;``````

Last edited:
Hey, is there a way to scan for the first 5 mins of the day? Thanks.

@wtan What are you trying to scan? If you're the scanning the code above then set the agg to 5 min and it'll be the first 5 mins of the day.

87k+ Posts
206 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?