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:

tomsk

Well-known member
VIP
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();
 

Big Ed

New member
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?
 

XeoNoX

Well-known member
VIP
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.
 

Big Ed

New member
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.
not doing it on my whole, that would be annoying to get notification on there.. I took the EXT check mark off for extended hours so lets see if that helps.
Is there a way to run more than 1 scan at a time with more than 1 watchlist by any chance?
 

XeoNoX

Well-known member
VIP
not doing it on my whole, that would be annoying to get notification on there.. I took the EXT check mark off for extended hours so lets see if that helps.
Is there a way to run more than 1 scan at a time with more than 1 watchlist by any chance?
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.
 

Big Ed

New member
so need help with this cuz today was the first day using this and I did not get a single alert. I created my watchlist for today and did custom study with the pm high low and took check mark out of ext. so what I did was run the scan before market opened so all my watchlist showed up on the scan screen. bunch of stocks broke the premarket high but I did not get a single alert on them. Am i doing something wrong? do I have to click the 3 lines on the right hand side to create the alert notifications? "alert when scan results change" and then asks me for watchlsit name.. that's the only part I had not done. I had it last week but it came off so will that fix the issue? is there a way to check this before tomorrow to see if it works?
 

XeoNoX

Well-known member
VIP
so need help with this cuz today was the first day using this and I did not get a single alert. I created my watchlist for today and did custom study with the pm high low and took check mark out of ext. so what I did was run the scan before market opened so all my watchlist showed up on the scan screen. bunch of stocks broke the premarket high but I did not get a single alert on them. Am i doing something wrong? do I have to click the 3 lines on the right hand side to create the alert notifications? "alert when scan results change" and then asks me for watchlsit name.. that's the only part I had not done. I had it last week but it came off so will that fix the issue? is there a way to check this before tomorrow to see if it works?
you have to post your code your using and the scanner settings you are using for anyone to be able to assist.
 

Big Ed

New member
the code is the above code for pm_high_low where it croses the premarket high supposed to alert you. My watchlist is list of stocks I add to look at for that day. So for scan setting I put Scan in "daily premarket movers" which is the watchlist that I create everymorning. and then for Study I do Custom and chose the pm_high_low, take check mark out of EXT and then click on 3 lines and chose set alert when scan results change. and then I have to put something in the field where is says "Scan name" and it has to be what I'm going to save the scan under correct? Am I missing anything else.
 

XeoNoX

Well-known member
VIP
because there are many settings for the scanner and sometimes it could be a small checkbox or settings that not set right ... ide recommend taking screenshots and posting it so it can be looked at better to try and figure out what happened
 

Big Ed

New member
I don't know how to upload pics on there. if anyone can help without a pic upload please let me know .thanks
 

Big Ed

New member
qglYy3w.png
 

Big Ed

New member
so there it is.. do I have to press scan first cuz if I do I don't get any new results and no alerts go off. I think I have it setup correctly just don't know at what time I have to run the scan or am I doing something wrong?
 

Big Ed

New member
at what point do I run the scan? do I have to wait till the market is open before running the scan? otherwise if I run it before market then no new symbols will be added. it brings my whole watchlist over to the scan.

Has anybody used this script successfully that can hep me figure this out? this is really important for me. I really need to make this work adn don't know how to test it without running it in real time.
 

XeoNoX

Well-known member
VIP
im not sure, i didn't really overlook the code since you didn't specify the code your using, but you can try it tomorrow and let us know. its easier to try and find out and let us know than someone taking the time to break down someone else's code.
 

rad14733

Well-known member
VIP
@Big Ed I agree with @XeoNoX... I had a reply typed up earlier, regarding a few aspects of the code, but decided not to post it... In all honesty, it would probably take me less time to write the code the way I code than to decipher someone else's code... Unfortunately, for you at least, this concept isn't something I'm all that interested in so my heart just wouldn't be into making an attempt... Another unfortunate issue is that the original poster of the code, @BigKrud, hasn't visited the site in over a year... Let's hope @XeoNoX can come through for you...
 

Big Ed

New member
I think I'm having some sort of issue with TOS. My alerts are not going off even for the indicators when I set it to go off when crossing pre market high. I don't know how to fix it. Any suggestion? that might be reason why my alerts are not working for the scanner.
 

Similar threads

Top