Here is a pre-market gap scanner for ThinkorSwim that looks for stocks with a 1% gap up or down from the previous close. Mobius shared this in the thinkScript lounge.
Here is another one:
Code:
Code:
# Scan PreMarket: Scan for 1 Percent gap from Previous Close
# Scan at 5 min aggregation or less
# Mobius
# Chat Room Request
def PrevClose = if SecondsTillTime(1555) == 0 and
SecondsFromTime(1555) == 0
then close
else PrevClose[1];
def ScanActive = if SecondsTillTime(0930) >= 0 and
SecondsFromTime(0730) > 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 gapUP = if ScanActive and ll > PrevClose * 1.01
then 1
else 0;
#plot gapDN = if ScanActive and hh < PrevClose * .99
# then 1
# else 0;
Here is another one:
14:34 davidanderson: Hello guys, wondering if anyone here has the code for column that would show %gap pre market (like total, since yesterday's close at 4pm). it's (the number that corresponds to After_Hours_Percent_change. but I can't express it in a column. thank you
14:35 Mobius: sectors that are stable.. not out of favor with the general trading world.
14:35 bigworm: so not a sector that is really volatilie
14:42 AlphaInvestor: Column must be set to 1 minute, with Extended Hours Session turned on
14:42 AlphaInvestor: This isn't really a "gap" just a change after-hours or pre-market
Code:
Code:
# PM_AH_Chg
#09:26 GapnGo: This worked as a watchlist column until we had the last big TOS update.
#09:27 GapnGo: anyone know what the problem is with the script
#09:37 Mobius: Gap.. Since the introduction of GetTime(), watchlists and mobile applications seem to work more reliably using it rather than SecondsTillTime() or SecondsFromTime()
#09:52 Mobius: Gap.. I think this will get it going
def Post = getTime() > RegularTradingEnd(getYYYYMMDD());
def Pre = getTime() < RegularTradingStart(getYYYYMMDD());
def Closed = Post or Pre;
def DayClose1 = if getTime() crosses RegularTradingEnd(getYYYYMMDD())
then close
else DayClose1[1];
#09:39 Mobius: Alpha.. I don't know why there'd be a difference but using cross vs crosses above does make a difference with some equities.
def DayClose2 = if getTime() crosses above RegularTradingEnd(getYYYYMMDD())
then close
else DayClose2[1];
#addLabel(1, "Prev Close = " + DayClose2);
def Change = Round((close - DayClose2), 2);
def Percent = Round(((close - DayClose2) / DayClose2) * 100, 2);
plot Xtended = If(Closed, Percent, 0);
AssignBackgroundColor(Color.BLACK);
Xtended.AssignValueColor(if !Closed then Color.YELLOW else if Percent > 0 then Color.GREEN else if Percent < 0 then Color.RED else color.gray);