Adding scan filter to show stocks that meet criteria in the final 2 hours only


Category:
0
0

First, thanks a ton for this forum. I’m already successfully using some custom scripts you’ve provided in other posts within my scans.

What I can’t seem to figure out is the following for a TOS scan:

How can I tell my scan to find stocks if they meet my filter criteria AND ONLY if they meet the criteria within the last 2 hours of regular market hours.

Currently I have some daily dollar volume scans running throughout the day, and stocks will appear on them as the $ volume threshold is met… but I would like to duplicate one of these scans and tell it show me only the stocks that meet the thresh hold in the last 2 hours of the day (and not before).

Technically, these stocks are showing up on the scans I already have, but by the end of the day, they’re mixed in with 20+ other stocks that were added throughout the morning and they’re difficult to separate (or know exactly when they appear). If I could create a scan for just those last 2 hours, the moment a stock pops up on it, I will know it’s what I’m looking for.

Any help is appreciated, thanks!

Jake

RESOLVED
Marked as spam
Posted by (Questions: 2, Answers: 6)
Asked on April 1, 2019 1:18 pm
119 views
0
Private answer

Add a new study filter using only these two lines of code. Set the time frame to 1 hour:

def sessionEnd =SecondsTillTime(1500) <= 0;
plot targetZone = sessionEnd[-1] or sessionEnd;

Marked as spam
Posted by (Questions: 37, Answers: 4086)
Answered on April 6, 2019 9:51 am
0

Amazing, thanks so much. Installed just now and will see how it goes later today!

( at April 8, 2019 8:03 am)
0
So I installed the script and it indeed started finding stocks only in the final 2 hours of regular market hours (check!). However, as my main filter for this scan is a $ Volume threshold, the scan is showing any/all stocks that met the $ Volume threshold at any point in the entire day — It’s just not revealing them until the final 2 hours. Put another way, the original scan finds every stock (within certain parameters) that also hits a certain $ Volume at any point in the entire day. It finds 1-2 stocks within the first 2 hours, 5-6 more midday, and by the end of the day it has maybe 10-15 stocks. It resets to 0 the next morning. What I’d like to do is use this same scan but reveal only the stocks that reach the $ Volume threshold *during* the final 2 hours of the day. I added your script above to the original scan, and once we reached the final 2 hours of market trading, 10-15 stocks popped up immediately — the same stocks that are found in the original scan. Is there a way for TOS to scan for the stocks that reach the $ Volume *only* in those final 2 hours (and not before)? It’s almost like it’s about starting the scan in the final 2 hours and somehow telling it to ignore any stocks that reached the $ Volume threshold during the previous 4.5 hours — therefore, the only stocks that show up are ones picking up strong volume at the *end of regular market hours* only.
( at April 9, 2019 8:01 am)
0

Ok, so you will need to apply my code directly to your volume study filter instead of adding this code as a separate study filter. But you did not provide the code for your volume filter and I cannot give you an exact solution. Basically, what you have for the plot statement on your volume filter, you will need to add the code for the “last two hour” filter.

So if you have this for volume filter:
plot scan = myVolumeFilter;

You would add my code and apply it to the end of your volume filter. Like this:
def sessionEnd =SecondsTillTime(1500)

( at April 9, 2019 10:15 am)
0
Ok, I think I understand, thank you. Here is the $ Volume filter for one of my scans (to catch VERY early dollar volume in certain microcap stocks where this would actually be unusual): def volumeDollars = Round(volume * hlc3, 0); def newDay = GetDay() GetDay()[1]; rec todaysVolumeDollars = if newDay then volumeDollars else todaysVolumeDollars[1] + volumeDollars; plot scan = todaysVolumeDollars > 15000; So the new end-of-day scan could look like this?: def volumeDollars = Round(volume * hlc3, 0); def newDay = GetDay() GetDay()[1]; rec todaysVolumeDollars = if newDay then volumeDollars else todaysVolumeDollars[1] + volumeDollars; plot scan = todaysVolumeDollars > 15000; def sessionEnd =SecondsTillTime(1500) The period I used for the original scan is Daily… but if I did the second script with the last element added in, should I change it to Hourly instead?
( at April 10, 2019 2:17 pm)
0

Currently, the scan I’m trying from my last comment — with the sessionEnd element added to the $ volume scan — is showing the same stocks as the original scan (and during mid-day trading). Hmmm, still not sure on what needs to change.

Here is the scan link: http://tos.mx/FAEL70

( at April 11, 2019 9:21 am)
0
Hi there, just checking in on my previous comments. Thank you!
( at April 26, 2019 7:33 am)
0
Sorry, I can see now that a portion of the code I provided in a previous comment was cut off and not included in the comment. As to your existing code for the volume filter. That code was not designed to work on a daily time frame. It will read the total daily volume from an intraday time frame. So be sure to set the time frame to 1 hour and apply the following:
def volumeDollars = Round(volume * hlc3, 0);
def newDay = GetDay() GetDay()[1];
rec todaysVolumeDollars = if newDay then volumeDollars else todaysVolumeDollars[1] + volumeDollars;
def sessionEnd =SecondsTillTime(1500) <= 0;
def targetZone = sessionEnd[-1] or sessionEnd;
plot scan = todaysVolumeDollars > 15000 and targetZone;
( at April 26, 2019 8:41 am)