Premarket After-market For ThinkOrSwim

@TheDakk if it doesnt work then that specific code just wont be compatible with the mobile version of thinkoswim, unfortunately some desktop thinkorswim scripts dont work on mobile as the mobile version has limitations, since the script uses current day and the nasdaq is closed, you may have to wait for a day when market is open and afterhours is active and then try again.
 

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

@XeoNoX Everything worked! :) The only thing I had a question about was
Code:
def today=getday()==getlastDay();
It looks like it's not even being called in that script? I removed the variable. I did make some minor tweaks to the time frame as well but ended up with these three columns for mobile:

AH Last
Code:
close

AH % Change
Code:
def close1 = if SecondsFromTime(0930) > 0 and SecondsFromTime(1600) < 0  then close else close1[1];
def change = (close / close1) - 1;
plot scan = round(change*100,2);
scan.AssignValueColor(if scan >= 0 then Color.UPTICK else Color.DOWNTICK);

AH Net Change
Code:
def close1 = if SecondsFromTime(0930) > 0 and SecondsFromTime(1600) < 0  then close else close1[1];
def change = close - close1;
plot scan = change;
scan.AssignValueColor(if scan >= 0 then Color.UPTICK else Color.DOWNTICK);

Also, doesn't like like colors work on custom quotes columns on mobile.
 
Last edited:
Premarket %change filter. Its no problem to filter % change in the normal hours. Is there anyway to filter the mark by % change in premarket? Seems like it would come in handy.
 
@westsail5000 There are studies and threads in the forum that calculate the % change in premarket, aftermarket, regular hours. if you want the mark just change (CLOSE) to (((ASK-BID)/2) + BID) which will give you the mark that is typically the middle price of the bid and ask.

Code:
(((ASK-BID)/2) + BID)
 
@BenTen, Is it possible to plot Premarket open? Aside from the Premarket High and LOW I would like to add Premarket open as well. As Always, Thank You for your amazing work.
 
After Market Hours Gainers

I know there is inbuilt After Market hours Scanner but I want to customize it 2% change in last 3 10 min bars data of after 4pm ET only to be considered. With addition filters I can add to this scan.

Also how do I add percentage change after market hours 4PM ET & volume after market hours 4PM ET columns to my watchlist.

Your help appreciated!
 
Thanks @XeoNoX, Sorting does not work for the column also how can I use this new column in Scanner I don't see in Stock filter.

p2ffvqk.png
 
is there an easy way to see if premarket hours exist? for example HLYK has no premarket hours or aftermarket hours. it goes from 3:59pm yesterday to 9:30am this morning.
 
i think i figured it out after a little testing. i will test some more...

Code:
def PreMktOpen = GetYYYYMMDD() != GetYYYYMMDD()[1];
def PreMktHrs = GetTime() < RegularTradingStart(GetYYYYMMDD());
def RegMktHrs = (GetTime() >= RegularTradingStart(GetYYYYMMDD())) and (GetTime() < RegularTradingEnd(GetYYYYMMDD()));

def pHigh = if PreMktOpen and PreMktHrs then high
            else if PreMktOpen and RegMktHrs then Double.NaN
            else if PreMktHrs and high > pHigh[1] then high
            else pHigh[1];

def pLow = if PreMktOpen and PreMktHrs then low
           else if PreMktOpen and RegMktHrs then Double.NaN
           else if PreMktHrs and low < pLow[1] then low
           else pLow[1];
 
Try this update to put a chart bubble on each line.

rSZuRf8.png


Code:
#
# see https://usethinkscript.com/threads/how-to-get-current-days-premarket-high.695/
#
declare once_per_bar;

input PlotPreMktLinesHrsPastOpen = yes;
input ShowChartBubbles = yes;

def bar = BarNumber();
def nan = Double.NaN;
def vHigh = high;
def vLow = low;

def PMhrs = RegularTradingStart (GetYYYYMMDD()) > GetTime();
def RMhrs = RegularTradingStart (GetYYYYMMDD()) < GetTime();
def PMStart = RMhrs[1] and PMhrs;
def PMHigh = CompoundValue(1, if PMStart then vHigh else if PMhrs then Max(vHigh, PMHigh[1]) else PMHigh[1], 0);
def PMLow = CompoundValue(1, if PMStart then vLow else if PMhrs then Min(vLow, PMLow[1]) else PMLow[1], 0);
def highBar = if PMhrs and vHigh == PMHigh then bar else nan;
def lowBar = if PMhrs and vLow == PMLow then bar else nan;
def PMHighBar = if bar == HighestAll(highBar) then PMHigh else PMHighBar[1];
def PMLowBar = if bar == HighestAll(lowBar) then PMLow else PMLowBar[1];

plot PMH =  if PlotPreMktLinesHrsPastOpen and PMHighBar != 0
            then PMHighBar
            else nan;
plot PML =  if PlotPreMktLinesHrsPastOpen and PMLowBar != 0
            then PMLowBar
            else nan;
plot PMMid = if PlotPreMktLinesHrsPastOpen and PMHighBar != 0 and PMLowBar != 0
             then (PMHighBar + PMLowBar) / 2
             else nan;

AddChartBubble(ShowChartBubbles and bar == HighestAll(highBar),
  PMHigh,
  "PM High",
  Color.Gray,
  1);

AddChartBubble(ShowChartBubbles and bar == HighestAll(lowBar),
  PMLow,
  "PM Low",
  Color.Gray,
  0);

AddChartBubble(ShowChartBubbles and bar == Max(HighestAll(highBar), HighestAll(lowBar)),
  (PMHighBar + PMLowBar) / 2,
  "PM Mid",
  Color.Gray,
  1);

# end of script
Thank you, exactly what I wanted. Midline a must.
 
Is there a way to have Labels for PMH ,PMMid and PML with price ? I hate lines and clutters, it would be nice if someone can mod this script . Right now I'm using this code with show study off so I only see chartbubble.
Thanks in advance
Ruby:
#
# see https://usethinkscript.com/threads/how-to-get-current-days-premarket-high.695/
#
declare once_per_bar;

input PlotPreMktLinesHrsPastOpen = yes;
input ShowChartBubbles = yes;

def bar = BarNumber();
def nan = Double.NaN;
def vHigh = high;
def vLow = low;

def PMhrs = RegularTradingStart (GetYYYYMMDD()) > GetTime();
def RMhrs = RegularTradingStart (GetYYYYMMDD()) < GetTime();
def PMStart = RMhrs[1] and PMhrs;
def PMHigh = CompoundValue(1, if PMStart then vHigh else if PMhrs then Max(vHigh, PMHigh[1]) else PMHigh[1], 0);
def PMLow = CompoundValue(1, if PMStart then vLow else if PMhrs then Min(vLow, PMLow[1]) else PMLow[1], 0);
def highBar = if PMhrs and vHigh == PMHigh then bar else nan;
def lowBar = if PMhrs and vLow == PMLow then bar else nan;
def PMHighBar = if bar == HighestAll(highBar) then PMHigh else PMHighBar[1];
def PMLowBar = if bar == HighestAll(lowBar) then PMLow else PMLowBar[1];

plot PMH = if PlotPreMktLinesHrsPastOpen and PMHighBar != 0
then PMHighBar
else nan;
plot PML = if PlotPreMktLinesHrsPastOpen and PMLowBar != 0
then PMLowBar
else nan;
plot PMMid = if PlotPreMktLinesHrsPastOpen and PMHighBar != 0 and PMLowBar != 0
then (PMHighBar + PMLowBar) / 2
else nan;

AddChartBubble(ShowChartBubbles and bar == HighestAll(highBar),
PMHigh,
"PM High",
Color.Gray,
1);

AddChartBubble(ShowChartBubbles and bar == HighestAll(lowBar),
PMLow,
"PM Low",
Color.Gray,
0);

AddChartBubble(ShowChartBubbles and bar == Max(HighestAll(highBar), HighestAll(lowBar)),
(PMHighBar + PMLowBar) / 2,
"PM Mid",
Color.Gray,
1);

# end of script
 
Last edited by a moderator:
@Xhrx The preferred method would be to use SecondsFromTime() and SecondsTillTime()...

Ruby:
def close1 = if SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) > 0 then close else close[1];
 
I have a question, since the market is from 8:30 to 15:00 should I change that data on the script?

I have employed, now it display, however After Hour Change % is not precise:
QCOM Shows 0.0 Variation however the AH% change is -0.04%
On the same way BL doesn't show KFY doesn't show
Vuzi has the same error: Shows 0.68, however the AH% Change is 1.31%

What am I doing wrong @rad14733 ?

Code:
def close1 = if SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) > 0  then close else close[1];
def change = (close / close1) - 1;
plot scan = round(change*100,2);
scan.AssignValueColor(if scan >= 0 then Color.UPTICK else Color.DOWNTICK);
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
321 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