Premarket After-market For ThinkOrSwim

the built in scanner for TOS for afterhours works fine that Len20 posted in post # 5....... Remember you should set it to 1 minute and also remember it only scans for afterhours of the SAME DAY... meaning that the time of day you are scanning has to be in afterhours. if you wake up next morning at market open and scan that means that since afterhours hasnt hit yet it will scan the previous day results.
 
I did as you suggested and here is what I get when scanning at 7 pm ET (after hours):

As you can see for the first Ticker CELZ Last: 0.0302 (which is close as of today) --- the Market Change % is 674.36% even though the current Bid / Ask is 0.0301 and 0.0310. So, clearly, the 674.36 refers to the increase since Open this morning.

My goal is to have a column that shows the AfterHoursPercent increase / decrease -- between close of today and current after hours Ask price. So, the AfterHoursPercent for CELZ should be (ASK price - Today's Close) / Today's Close X 100 which is ....

(0.0310 - 0.0302) / 0.0302 * 100 = 2.65% -- NOT 674.36%.

PVtIoSZ.png


Can someone kindly suggest how one can accomplish this?

Thanks!
 
Here you go, it only works as a COLUMN.

It's a little off since it uses the current middle price, but its better than nothing, I'm sure there's a way to grab the price using secondsfromtime to grab the close/last afterhours.. I already had this one that I used... here is the code.

remember to hit the like button if you found my post usefull

PERCENT FROM MARKET CLOSE for use with AFTERHOURS

r4Vvklx.png


Code:
# in place.
#PERCENT FROM MARKET CLOSE for use with AFTERHOURS
#BY XeoNoX via usethinkscript.com
def middleprice = (ask-bid) / 2 + bid;
plot x = round(100*((middleprice/close)-1),1);
AddLabel(yes,aspercent(x/100),if x > 0 then color.UPTICK else if x == 0.0 then color.white else color.red);
 
Last edited:
Or the other work around would be, is there a way to turn off the premarket/afterhours affect that it has on your indicators, like VWAP and your moving averages? The premarket data skews the data with the low volume premarket/afterhours stuff.
 
Yes, that works, but then you can't see the lines from premarket or reference the visual support and resistance without manually going thru each ticker you are looking at and marking the levels? No way to script this "job?"

I also tried the <>Start aggregations at market open<> setting under Equities and I'm not sure what that does because it still skews the data on your indicators, quite a bit.

This script is a work of art, very well done. Happy New Year think scripters...
 
Last edited:
This is very helpful.

There are 2 queries:

1. My column, marked %ChgClose on the right, has a large number of entries marked "custom expression subscription limit exceeded". I researched this and it seems there is a supposed limit on how many results might be returned for custom code. However, I get 50% of entries like this even when I have only 20 or 30 results in the column. Any suggestions on how to get rid of this -- and get clean code like yours?

2. My Mark%Change column shows the % difference between the day's opening price and the after hours price - e.g. see 2nd Stock - NCTY - Mark%Change is 124%. How can I get the % difference between day's closing price and after hours price i.e. 28.9% ((19.2-14.89)/14.89*100).

Thank you!

k84Ft7R.png
 
Here you go, it only works as a COLUMN.

It's a little off since it uses the current middle price, but its better than nothing, I'm sure there's a way to grab the price using secondsfromtime to grab the close/last afterhours.. I already had this one that I used... here is the code.

remember to hit the like button if you found my post usefull

PERCENT FROM MARKET CLOSE for use with AFTERHOURS

r4Vvklx.png


Code:
# in place.
#PERCENT FROM MARKET CLOSE for use with AFTERHOURS
#BY XeoNoX via usethinkscript.com
def middleprice = (ask-bid) / 2 + bid;
plot x = round(100*((middleprice/close)-1),1);
AddLabel(yes,aspercent(x/100),if x > 0 then color.UPTICK else if x == 0.0 then color.white else color.red);

Not sure if you saw my next post in reply the one above. Bumping this, in case you didn't see it.

Thanks in advance for any help -- because this is out of my league :)!
 
Good day. Please help with new scanner, which will count bars on Aftermarket /Premarket hours (A/P hrs), compare last A/P hrs and previous, and will choose shares if last A/P bars is more than last A/P bars. On screen below is example where we can see on last A/P session 6 bars, on previous only 4 (9:00 bar is excluded from count)

bkrvF8T.jpg
 
I was trying to setup Column 3 in post #20, but it returns an insane number for all stocks. I assume it's not calculating correctly.

I would like to add the After Hours static number and percentage columns with the values that you see on many financial websites. Can anyone assist with this? I'm very new to thinkorswim desktop app. Thanks!
the code works, you have to fine tune your results to your liking with the scanner if you want to fine tune the results more, your saying on financial website but you didnt include a picture so i have no clue what you mean as there are various website with different assets and asset prices with different criteria.
 
the code works, you have to fine tune your results to your liking with the scanner if you want to fine tune the results more, your saying on financial website but you didnt include a picture so i have no clue what you mean as there are various website with different assets and asset prices with different criteria.
Apologies, I'm new to this. I pasted the code into the Custom 1 (Custom Quote) formula field and then added the column to the MarketWatch list, perhaps I'm doing it wrong? I wanted to be able to use the column in the mobile app as well. Here are some screenshots from Yahoo and Google with After hours numbers and percentages.

nhxfie9.png


Z2DKqrB.png
 
@TheDakk the post #20 by @axlerod works, you have to include extended hours in the scanner/columns and just set it for 1 minute... look up you tube videos on how to setup columns scanners and scanners for afterhours. here is the scanner portion since he had it as a label.

fob8CT2.png



AFTERHOURS SCAN WATCHLIST by Nick_Peist
Code:
# Follow @Nick_Peist on Twitter
# 1m Time Frame CHECK "included Extended Hours"
def today=getday()==getlastDay();
def close1= if secondsfromTime(1200)>0 and secondsFromTime(1600)<0  then close else close1[1];
def change= (close(pricetype=pricetype.last)/close1)-1;
addlabel(yes,round(change*100,2)+"%",if change>0 then color.green else color.red);
 
Last edited:
@XeoNoX Thank you, I will look at this. Appreciate the pointers!

Edit: Got it to work after making those changes :)

Edit2: Doesn't seem to work on mobile when I add the Custom Quote column, is the code different for the mobile platform?
 
Last edited:
I am looking for a study that will plot all of the following AND lines should only extend to the right from these points. Is it possible?

Previous Day Close (PDC)
After Hours High (AHH)
Premarket High (PMH)
Premarket Low (PML)
Market Open (MO)

@BenTen
This indicator does not include AHH, can anyone add this?

aMbXCIZ.jpg
 
Last edited:
Hi All! Can someone provide me a script so I can see after hours stock % moves like in Robinhood. Looking to add that into my watchlist on my dash board. Not tying to scan for this information. Any help would be amazing! I had it on my old computer but it no longer worked didn't work with the new computer for some reason. I believe it was this script:

Code:
def todaypostmarket = if GetLastDay() == GetDay() and SecondsFromTime(0930) >= 23400 then 1 else 0;

def timecondprice = if todaypostmarket then close else Double.NaN;

def firstbar = LowestAll(if todaypostmarket then BarNumber() else Double.NaN);

def firstbarprice = if IsNaN(if BarNumber() == firstbar then open else Double.NaN) then firstbarprice[1] else if BarNumber() == firstbar then open else Double.NaN;

def price = if todaypostmarket then close else price[1];

def change = if IsNaN((price - firstbarprice) / firstbarprice) then change[1] else (price - firstbarprice) / firstbarprice;

plot pcntchange = change * 100;
 
@saashby You said "so I can see after hours stock % moves like in Robinhood"

Not everyone knows that that means, you will have to post a picture and explain.
 
@TheDakk For mobile try removing the AddLabel() and change it to PLOT.

Code:
def today=getday()==getlastDay();
def close1= if secondsfromTime(1200)>0 and secondsFromTime(1600)<0  then close else close1[1];
def change= (close(pricetype=pricetype.last)/close1)-1;
plot scan = round(change*100,2);
 
@geebeeaye you are asking for AHH unless thats a futures chart the picture i assume shows what appears to be the previous day's after hours high. considering you didn't post the entire chart and are requesting a time based study withuot showing the time on your chart that means you will have to be more specific.
 
@XeoNoX I was able to get the code to work in the Desktop app using "plot", but it still only shows a hyphen in the watchlist column on mobile.

I think he wants what I want basically, Robinhood shows the % change after hours like I have in my screenshots.
 

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
332 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