Scan for Stocks Above/Below Pre-Market in ThinkorSwim

BigKrud

New member
Hey guys, this is my first post here. The information you can find on this forum is so unbelievably valuable and I've learned so much already from exploring all the different strategies and testing out different indicator combinations myself (with a good amount of success). I can't thank everyone enough who posts here, it's an amazing resource.

One thing I couldn't find when I was digging around, however, was a simple custom scan to add to scan queries that looks for stocks Above their Pre-Market High level. I use this for day trading and swing trading to find stocks that tend to break above these levels and continue their trend throughout the morning or into the next day.

I changed the bottom few lines so that it can be used for scans.

Here is the code:

Code:
#pm_high_low


input alertPeriodStart = 930;
input alertPeriodEnd = 1130;
input alertOnBreak = no;
input alertOnPullBack = no;
input numberOfDays = 2;
input numberOfYears = 0;


def okToPlot = GetLastDay() - numberOfDays <= GetDay() and GetLastYear() - numberOfYears <= GetYear() ;

def startCounter =  SecondsFromTime(alertPeriodStart);
def endCounter = SecondsTillTime(alertPeriodEnd);

def alertPeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;

def regularSessionHours = RegularTradingStart(GetYYYYMMDD()) <= GetTime();
def extendedSessionHours = RegularTradingStart(GetYYYYMMDD()) >= GetTime();

def extendedSessionStart = regularSessionHours[1] and extendedSessionHours;
def regularSessionStart = extendedSessionHours[1] and regularSessionHours;

def extendedSessionHigh = CompoundValue(1, if extendedSessionStart then high else if extendedSessionHours then Max(high, extendedSessionHigh[1]) else extendedSessionHigh[1], high);

def extendedSessionLow = CompoundValue(1, if extendedSessionStart then low else if extendedSessionHours then Min(low, extendedSessionLow[1]) else extendedSessionLow[1],low);

def regularSessionHigh = CompoundValue(1, if regularSessionStart then high else if regularSessionHours then Max(high, regularSessionHigh[1]) else regularSessionHigh[1], 0);

def regularSessionLow = CompoundValue(1, if regularSessionStart then low else if regularSessionHours then Min(low, regularSessionLow[1]) else regularSessionLow[1], 0);


plot overnightHigh = close > extendedSessionHigh;

#plot overnightLow = close < extendedSessionLow;

If you're looking for stocks that are Below the Pre Market Low level, just switch the hashtag on the last two lines.
 
Last edited by a moderator:
If anyone is having a go at decoding the actual times that extended session hours entails, here is a quick way to determine that.
Run the following code on a 1 minute chart of /ES. You will see visually those timeframes.
This is the best way of making sure you're looking at the correct time bracket.

Code:
declare lower;
plot extendedSessionHours = RegularTradingStart(GetYYYYMMDD()) >= GetTime();
 
thank you for sharing. I'm having issues where I'm still getting alerts after market has closed. From what is see it's only supposed to be active from 930am to 1130am EST. Any idea how I can fix this?
 
thank you for sharing. I'm having issues where I'm still getting alerts after market has closed. From what is see it's only supposed to be active from 930am to 1130am EST. Any idea how I can fix this?
just TD Amertirade glitch (late alerts) or its your phone carriers sms/text sending/receiving late. nothing you can do, ill get alerts on the weekends even sometimes.


just add another watchlist and and whatever scans you want to it. The alerts come from the watch list, which the watchlist is based of whatever scan or scans you choose for that particular watchlist.
 
Last edited by a moderator:
so the alerts all of a sudden started working today but like you said they are delayed so it just defeats the whole purpose of breaking the pre market high for me to get in for momentum play. that delay is not gonna cut it. I just have to fix the alert for the chart indicator I guess and just put 18-20 stocks on the charts and go from there. Now I have to figure out why the alerts on the charts are not working
 
correct, its why i would recommend for you to scan for when price is within XYZ% of the premarket high
that way you can see the tickers that are getting close to the premarket high live from the watchlist.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
225 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top