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!