Useful Intraday Stats for ThinkorSwim

S

soary

Member
Hi @Sonny, The labels showed up aftermarket with the volume stats for aftermarket hours. I am guessing that it will update during RTH. I'll let you know. Thanks
 
S

soary

Member
@Sonny, thank you very much, all the updated scripts work great. It shows the price and volume stats for the current session whether it's RTH or extended hours, the premarket open so can know the gap and it works with any market including futures. .Happy trading everyone!
 
Z

zkl123

New member
@Sonny , I like the code for VWAP difference. It shows "AV" for above VWAP and "BV" for below it. Is there any way can shows in percent value at watchlist column when the close price up/below vwap( how far from VWAP). thanks anyway.
 
S

Sonny

Active member
VIP
I revised the code again and now it shows premarket volume and premarket relative volume. Keep in mind that premarket volume label is not exact since it's hard to measure but this label is a great approximation of it.

Code:
#LABELS
#
#Current Price
AddLabel (1, "P: " + Round(close, 2), Color.CYAN);

#Percent Change from yesterday close
def AP = AggregationPeriod.DAY;
def Priorclose = close(period = AP)[1];
def PctChange = (close - Priorclose) / Priorclose;
def PC1 = Round(PctChange, 3);
AddLabel(1, "Ch: " + AsPercent(PC1), if PctChange > 0 then CreateColor(238, 210, 238) else CreateColor(255, 153, 153));

#Check if time is premarket
def pmopen = if SecondsFromTime(0400) >= 0 and SecondsTillTime(0930) >= 0 then 1 else 0;
def pmclosed = if SecondsFromTime(0400) >= 0 and SecondsTillTime(0930) >= 0 then 0 else 1;
def pastten = if SecondsFromTime(0400) >= 0 and SecondsTillTime(1000) >= 0 then 1 else 0;

#Prior Close
AddLabel (1, "Y: " + Round(Priorclose, 2), Color.LIGHT_GREEN);

#Open price
def open1 = open(period = AP);
AddLabel (pmclosed, "O: " + Round(open1, 2), CreateColor(254, 216, 177));

#High of Day
def high1 = Highest(high(period = AP), 1);
AddLabel (pmclosed, "H: " + Round(high1, 2), Color.CYAN);

#Low of Day
def low1 = Lowest(low(period = AP), 1);
AddLabel (pmclosed, "L: " + Round(low1, 2), CreateColor(178, 255, 102));

#Volume Today
def today = volume(period = AP);
def L1 = RoundDown(Lg(today), 0);
def M1 = if L1 > 5 and L1 < 8 then 1 else 0;
AddLabel (L1 < 5, "V: " + today, CreateColor(144, 171, 255));
AddLabel (L1 between 4.5 and 5.5, "V: " + Round((today / 1000), 0) + "K", CreateColor(144, 171, 255));
AddLabel (M1, "V: " + Round((today / 1000000), 1) + "M", CreateColor(206, 177, 128));
AddLabel (L1 > 7, "V: " + Round((today / 1000000), 0) + "M", CreateColor(206, 177, 128));

#Change From Open
def CFO = Round(100*((close/open1)-1),1);
AddLabel(pmclosed, "C: " + CFO + "%", if CFO > 0 then CreateColor(0, 255, 128) else CreateColor(255, 153, 153));

#Relative Volume
def AV = AggregationPeriod.DAY;
def x1 = Average(volume(period = AV)[1], 60);
def v1 = volume(period = AV);
def z1 = v1 / x1;
def z2 = if Lg(z1) >= 2 then 0 else 1;
AddLabel(pmclosed, "R: " + Round(z1, z2), CreateColor(208, 209, 238));
#Addlabel(1,x1,color.PINK);

def h = high;
def v = volume;
def bar = BarNumber();
def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());

#Premarket Volume
def vol = if GlobeX and !GlobeX[1] then v else if GlobeX then vol[1] + v else Double.NaN;
def L2 = RoundDown(Lg(vol), 0);
def C1 = if L2 > 4.5 and L2 < 5.5 then 1 else 0;
AddLabel (pmopen and L2 < 5, "PV: " + vol, CreateColor(196, 212, 207));
AddLabel (pmopen and C1, "PV: " + Round((vol / 1000), 0) + "K", CreateColor(196, 212, 207));
AddLabel (pmopen and L2 > 5, "PV: " + Round((vol / 1000000), 1) + "M", CreateColor(196, 212, 207));

#Premarket Open
def newDay = GetDay() <> GetDay()[1];
def start = newDay or SecondsTillTime(400) == 0;
rec premarketOpen = if start then open else premarketOpen[1];
def x = premarketOpen;
AddLabel(pmopen, "PO: " + Round(x, 2), CreateColor(110, 160, 208));

#Premarket High
def ONhigh = if GlobeX and !GlobeX[1] then h else if GlobeX and h > ONhigh[1] then h else ONhigh[1];
def ONhighBar = if GlobeX and h == ONhigh then bar else Double.NaN;
def OverNightHigh = if BarNumber() == HighestAll(ONhighBar) then ONhigh else OverNightHigh[1];
AddLabel(pastten, "PH: " + Round(OverNightHigh, 2), Color.CYAN);

#Pct difference between price and premarket open
def z = Round(100 * ((close / x) - 1), 1);
AddLabel(pmopen, "PG: " + z + "%", if z < 0 then CreateColor(255, 153, 153) else CreateColor(197, 239, 161));

#Premarket Relative Volume
def z3 = vol / x1;
AddLabel(pmopen, "PR: " + Round(z3, 2), CreateColor(254, 216, 177));
 
E

eyesuk

New member
Good morning @Sonny,
I just wanted to come in here and say thank you very much for your efforts, this is awesome!

Where can I send you beer money?
Hope you and your love ones are all safe and healthy
 
S

Sonny

Active member
VIP
Good morning @Sonny,
I just wanted to come in here and say thank you very much for your efforts, this is awesome!

Where can I send you beer money?
Hope you and your love ones are all safe and healthy
Thanks for your support! I really love trading and want to contribute to make it easier for others to get info without searching for it.
 
S

Sonny

Active member
VIP
@Sonny , I like the code for VWAP difference. It shows "AV" for above VWAP and "BV" for below it. Is there any way can shows in percent value at watchlist column when the close price up/below vwap( how far from VWAP). thanks anyway.
Here is the column code for percent above or below VWAP:

def x = vwap;
def y = Round((100*(close/vwap)-1),1);
plot z=y;
z.assignValueColor(if y>0 then color.GREEN else color.RED);
 
Last edited:
K

k8be

New member
Hi Sonny,

Thanks for your piece of code.
Is your gap different than your momentum scan?
What's the difference?
 
Last edited:
Z

zkl123

New member
@Sonny , thank you very much, the code works great. Much appreciated.
 
S

Sonny

Active member
VIP
Hi Sonny,

Thanks for your piece of code.
Is your gap different than your momentum scan?
What's the difference?
My gap scan is listed below:

Last: 1 to 15
% change: 15 to No Max
Volume: 100,000 to No Max

The difference in gap and Momentum scans is this - Gap scan shows you the highest percent gainers for the day but momentum scan shows which stocks have high percent gains but also positive change from open percentage as well.
 
K

k8be

New member
Thank you for explanation, and of course gap scan is valid both pre-market and regular trading!
One more question.
The previous code you shared the pre-market RV1 and the regular Rv1, I didn't get different numbers between the two the numbers come out the same always. what's the difference?
Or are they the same. Thank you for your willingness to help.
 
Last edited:
S

Sonny

Active member
VIP
@k8be The premarket RV1 is (PM volume) / (60 day aver. volume) and the regular RV1 is (today's volume) / (60 day aver. volume). I coded it so premarket RV1 stops showing up after 9:31 and the regular RV1 is shown after that.
 
K

k8be

New member
@k8be The premarket RV1 is (PM volume) / (60 day aver. volume) and the regular RV1 is (today's volume) / (60 day aver. volume). I coded it so premarket RV1 stops showing up after 9:31 and the regular RV1 is shown after that.
That makes so much sense now! Got it. I was mixing them up.

Do you take any relationship going from gap scan to mom scan, to filter the tickers.
I know you said focus on top 3 rV, like today EQ was not #1 even though it was the clear winner.

What I did was to look at the results and check the news for each one.


From your code, if I am in the west coast using PDT, do I need to change this time to 0630 instead of 0930 and 0100 instead of 0400?
#Check if time is premarket
def pmopen = if SecondsFromTime(0400) >= 0 and SecondsTillTime(0930) >= 0 then 1 else 0;
def pmclosed = if SecondsFromTime(0400) >= 0 and SecondsTillTime(0930) >= 0 then 0 else 1;
def pastten = if SecondsFromTime(0400) >= 0 and SecondsTillTime(1000) >= 0 then 1 else 0;
 
zeek

zeek

Active member
2019 Donor
Very nice contributions to this thread @Sonny (y)

Was wondering if you could possibly make two labels for me that shows the following,

1. Traded volume for pre-market. I only need it to show traded volume from 4:00AM to 09:30AM.
2. The RVOL in pre-market over a 10 day period comparing the relative volume only between 04:00AM to 09:30AM

Would be great if you could make these two labels:)
 
S

Sonny

Active member
VIP
That makes so much sense now! Got it. I was mixing them up.

Do you take any relationship going from gap scan to mom scan, to filter the tickers.
I know you said focus on top 3 rV, like today EQ was not #1 even though it was the clear winner.

What I did was to look at the results and check the news for each one.


From your code, if I am in the west coast using PDT, do I need to change this time to 0630 instead of 0930 and 0100 instead of 0400?
#Check if time is premarket
def pmopen = if SecondsFromTime(0400) >= 0 and SecondsTillTime(0930) >= 0 then 1 else 0;
def pmclosed = if SecondsFromTime(0400) >= 0 and SecondsTillTime(0930) >= 0 then 0 else 1;
def pastten = if SecondsFromTime(0400) >= 0 and SecondsTillTime(1000) >= 0 then 1 else 0;
EQ was definitely #1 in RV today, then ECOR, then ANTE and they all spiked at some point. If you are in west coast, then change the times in the code like you said.
 
K

k8be

New member
EQ was definitely #1 in RV today, then ECOR, then ANTE and they all spiked at some point. If you are in west coast, then change the times in the code like you said.
Thank you! @Sonny, yes, as you said it did up #1. morning time I checked it hadn't moved up the list. Makes sense the tool is dynamic.

I want to follow what zeek has requested to ask for a Column version in Watchlist that will show only pre-market volume (instead of label version)
1. Traded volume for pre-market. I only need it to show traded volume from 4:00AM to 09:30AM.
2. The RVOL in pre-market over a 10 day period comparing the relative volume only between 04:00AM to 09:30AM

Thank you.
 
S

Sonny

Active member
VIP
@k8be

TOS does not keep track of premarket volume for different days so you cannot compare these values. The most important stat is relative volume, not just premarket volume. If the premarket relative volume is greater than 1, then you know that the RV for the day will be big. The PM volume as a column already exists as "Volume"!
 
K

k8be

New member
@k8be

TOS does not keep track of premarket volume for different days so you cannot compare these values. The most important stat is relative volume, not just premarket volume. If the premarket relative volume is greater than 1, then you know that the RV for the day will be big. The PM volume as a column already exists as "Volume"!
Thank you.
 
R

risentrade

New member
It has been a while was hunting for Pre Mkt volume.
Finally stumble upon this have made some changes see if this helps.

input PreMktVol = yes;
input PostMktVol = yes;
input PrestartTime = 0400;
input PreendTime = 0929;

def PreMkt = SecondsFromTime(PrestartTime) >= 0 and SecondsTillTime(PreendTime) >= 0;
def PreVolMins = if PreMkt and !PreMkt[1] then volume
else if PreMkt then PreVolMins[1] + volume
else PreVolMins[1];
AddLabel(if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if PreMktVol then 1 else 0, "PreMktVol = " + Round(PreVolMins * .000001, 2) + "M", Color.YELLOW);

# End Volume PreMarket

input PoststartTime = 1600;
input PostendTime = 1959;

def PostMkt = SecondsFromTime(PoststartTime) >= 0 and SecondsTillTime(PostendTime) >= 0;
def PostVolMins = if PostMkt and !PostMkt[1] then volume
else if PostMkt then PostVolMins[1] + volume
else PostVolMins[1];
AddLabel(if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if PostMktVol then 1 else 0, "PostMktVol = " + Round(PostVolMins* .000001, 2) + "M", Color.YELLOW);

# End Volume PostMarket
 
E

EricsLiberty

New member
can anyone please explain the bars for this indicator, what does the, blue P: , purple Ch: , brown O: , Green C: , and purple R: bars mean?
thanks
 
Top