Scan within a specific hour time range


Category:
0
0

I am trying to narrow down my tos scan further by hopefully being able to add a timeframe between lets say hours 1500 to 0630 but more so want to be able to set different times so it only scans between those hours.  Is that a possibility?

 

Thanks!

Marked as spam
Posted by (Questions: 3, Answers: 1)
Asked on July 15, 2019 12:23 pm
993 views
0
Only if your Study Filter is set to intraday. What time frame do you plan to use for this?
( at July 15, 2019 3:59 pm)
0
Between 1m and 15 mins.
( at July 16, 2019 1:50 pm)
0
Private answer

For starters, it's crucial to know the time zone used in Scans is always set to Eastern time zone. From the start and end times that you listed in your post it seems you are interested in scanning for a time zone other than Eastern. Be sure to consider this when adjusting the inputs. Here is the code along with a screenshot showing the result plotted on a lower subgraph. The chart here is set to Eastern time zone to match what is used by the scan engine on Thinkorswim.

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

Edit: If you happen to be using the code for a start time and end time that does not span midnight, you will have to adjust the last line of the code as follow:

plot scanPeriod = startOfScan and endOfScan;

To make this perfectly clear, you will need to use that modified statement if you have your start time set to 600 and the end time set to 929. Those two times do not have midnight between them. The original version of that statement should only be used of your start time is before midnight and your end time is after midnight. Thanks to valerol for helping me to discover this tweak!

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on July 16, 2019 2:18 pm
0
I have updated my answer to provide a tweak to the last line of code if your start and end times do not cross from one day to the next.
( at April 29, 2020 12:31 pm)
0
Hi Pete! Unfortunately this is not working either. Yesterday I kept receiving the alerts outside of my start and end times.
( at April 30, 2020 3:38 am)
0
Worked perfectly when I tested it. I suggest you go back and make sure you structured everything correctly.
( at April 30, 2020 7:07 am)
0
Mine is working fine now. Strange that it needed all day yesterday to finally get fixed. Thanks again!
( at April 30, 2020 7:44 am)