Time limit code

CHOZEN

CHOZEN

New member
VIP
Looking for some help. Anyone know how to write a code to place in my scanner that will only scan premarket from 4am - 9:30am
 
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
By only scanning during pre-market. You can also use the “within X bars” as a lookback period.
 
markos

markos

Well-known member
VIP
Warehouse
@chosen Type the word Universe in the search box above. I know that there are more than one of those scanners in there, but you will have to hunt.
 
korygill

korygill

Member
VIP
Warehouse
Search code here that uses SecondsFromTime and SecondsTillTime. You may need to adjust for your timezone.

I use a variable in all my scripts like
input timeOffsetFromEST = -300; #hint timeOffsetFromEST: 24-hour time offset from EST (-300 for PST)

and then
startTime = 0630 - timeOffsetFromEST;
endOfTradingTime = 1315 - timeOffsetFromEST;

and then maybe something like
def isActive = if SecondsTillTime(endTime) > 0 and SecondsFromTime(startTime) >= 0
then 1
else 0;

def atEndTime = if secondsTillTime(endTime) == 0
then 1
else 0;
 

Top