Premarket Gap Scanner - $2 Gap

A

adammajcher

New member
Hello,

I'm trying to write a premarket scanner that scans for tickers that have at least a 200M market cap, as well as, have a $2 gap from the previous market close. So far I have used this code, https://usethinkscript.com/threads/pre-market-gap-from-previous-close-scanner-for-thinkorswim.892/, to start. I have set the aggregation period for less than 5 minutes.
Problem is, a 1 min aggregation gives me 50 tickers but TSLA is not one of them, even though that's what my scanner filters for.

def PrevClose = if SecondsTillTime(1600) == 0 and
SecondsFromTime(1600) == 0
then close
else PrevClose[1];
def ScanActive = if SecondsTillTime(0930) >= 0 and
SecondsFromTime(0400) > 0
then 1
else 0;
def ll = if ScanActive and !ScanActive[1]
then low
else if !ScanActive
then double.nan
else if ScanActive and low < ll[1]
then low
else ll[1];
def hh = if ScanActive and !ScanActive[1]
then high
else if !ScanActive
then double.nan
else if ScanActive and high > hh[1]
then high
else hh[1];
# Comment out (#) Plot NOT wanted
plot gap = if ScanActive and ((ll > (PrevClose + 2)) or (hh < (PrevClose - 2)))
then 1
else 0;
 

Similar threads

Top