Useful Intraday Stats for ThinkorSwim

V

Vimal Mittal

Member
if market opens at 9;30, Will i see the volume green color with high number right away, if it is very high for that particular stock in my watchlist?
same for red too?
The reason I ask because it is difficult to find a stock in early morning showing high volume in my scan. It does not show early in morning.
Thanks.
 
S

Sonny

Active member
VIP
@Vimal Mittal The volume label will show at 9:30. However, you can see premarket volume by adding Volume as a watchlist column in your scan.
 
S

soary

Member
The volume label will show at 9:30. However, you can see premarket volume by adding Volume as a watchlist column in your scan.
@Sonny good to know, I was wondering about that but figured it's for RTH but also, I found a script on here for premarket volume that I pieced in:
https://usethinkscript.com/threads/premarket-relative-volume-percentage-watchlist.1297/
Thanks to you I have some great labels and no more hunting around for those stats. Since market is closed I placed them on a daily chart of the /ES and they show up good and accurately. I'll see how they work out in premarket and RTH
 
S

Sonny

Active member
VIP
I have revised the original code and now has more features, including premarket stats as well.

Please use this code:

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, "YC: " + 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);
AddLabel (L1 < 5, "V: " + today, CreateColor(206, 177, 128));
AddLabel (L1 between 4.5 and 5.5, "V: " + Round((today / 1000), 0) + "K", CreateColor(206, 177, 128));
AddLabel (L1 > 5, "V: " + Round((today / 1000000), 1) + "M", CreateColor(206, 177, 128));

#Change From Open
def CFO = (close / open1) - 1;
def CFO1 = Round(CFO, 3);
AddLabel(pmclosed, "C: " + AsPercent(CFO1), 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;
Addlabel(pmclosed, "R: "+ Round(z1,1), createcolor(208,209,238));

#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, "PMO: " + Round(x,2), createcolor(110,160,208));

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

#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, "PMH: " + Round(OverNightHigh,2), color.CYAN);

#Pct difference between price and premarket open
Def z=Round(100*((close/x)-1),1);
Addlabel(pmopen, "PMG: " + z + "%", if z <0 then createcolor(255,153,153) else createcolor(197,239,161));
 
Last edited by a moderator:
S

Sonny

Active member
VIP
@Sonny it's possible to write the code for the volume on a current bar in any timeframe?
Here is the code for volume tracking. V4 is the current volume, V1 is volume 1 min ago, V2 is volume 2min ago, and V3 is volume 3 min ago. You can customize it if you want.

#Volume tracker
def AP = AggregationPeriod.MIN;
def V1 = volume(period = AP)[1];
def V2 = volume(period = AP)[2];
def V3 = volume(period = AP)[3];
def V4 = volume;
Addlabel (1,"V3: "+V3,color.LIGHT_ORANGE);
Addlabel (1,"V2: "+V2,color.PINK);
Addlabel (1,"V1: "+V1,color.LIGHT_GREEN);
Addlabel (1,"VN: "+V4,color.CYAN);
 
S

Sonny

Active member
VIP
This code is only for chart labels. The watchlist columns already have most of this data. You just have to add it to your columns.
 
R

RochaTheRock

New member
Hey @Sonny it does not pop up anything in the charts. Do I need to change something?
 
V

Vimal Mittal

Member
This code is only for chart labels. The watchlist columns already have most of this data. You just have to add it to your columns.
ok thanks a miilion! This is working very well.
 
S

Sonny

Active member
VIP
Hey @Sonny it does not pop up anything in the charts. Do I need to change something?
The volume labels show up at the bottom in the volume section if you are using the big chart but they show up in the chart if using the flexible grid (small charts).
 
J

Johnny Cash

Member
It is getting better and better. Thanks for all the hard work. I don't want to abuse of your generosity, but is there a label that I can add to tell percentage change of today's volume to yesterday volume
 
S

Sonny

Active member
VIP
@Johnny Cash

Just add this code to the bottom of the big code I posted above this reply:

#Pct diff between today and yest volume
def x2 = volume(period=AP)[1];
def x3 = Round(100*((today/x2)-1),1);
Addlabel(pmclosed, "Vc: "+x3+"%", if x3>0 then createcolor(97,217,244) else createcolor(255,153,153));
 
Last edited:
S

soary

Member
Hi @Sonny it is getting better and better, thanks for your work. All the parts of the code worked except for the volume codes. It did not show up on Thursday during RTH and has no errors in TOS. I see you changed some things so I updated the scripts with the new changes. i'll see if they show up on Monday during RTH and let you know. Here's the volume portion of the scripts throughout the thread that I need:

Code:
#Sonny @ usethinkscript.com

input v = volume;
input aggregationPeriod = AggregationPeriod.DAY;
def AP = AggregationPeriod.DAY;

#Yest Vol
def YV = v[1];
def YVL = RoundDown(Lg(YV), 0);
Addlabel(1, “YV” + V[1], CreateColor(206, 177, 128));

#Volume today
def VT = volume(period = AP) ;
AddLabel(1, "VT: " + V, CreateColor(206, 177, 128));

#Dif bet yest volume and today
def difvol = YV - V;
AddLabel(1, "2D VOLD: " + difvol, Color.PINK);

#Relative Volume 2d
def volD2d = volume(period = volD2d);
def z = Average(volume(period = volD2d)[1], 2);
def volD2dR = v/z;
Addlabel(volD2dR, " volD2dR: "+ Round(volD2dR,1), createcolor(208,209,238));

#Relative Volume 100d
#Average Volume in (100d)
def AV = volume(period = AV);
def x = Average(volume(period = AV)[1], 100);
def ARV = v/x;
Addlabel(ARV, "ARV: "+ Round(ARV,1), createcolor(208,209,238));

#Difference between AV and today's volume
def AVD = x-v;
Addlabel(AVD, "AVD: "+ Round(AVD,1), createcolor(208,209,238));
 
S

soary

Member
Hi @Sonny as I posted earlier the volume parts of the code throughout the tread didn't work during RTH even with the updates..
 
V

Vimal Mittal

Member
The volume label will show at 9:30. However, you can see premarket volume by adding Volume as a watchlist column in your scan.
Are you saying this script I can use for premarket as well? I tried but it works only when market opens. I m new and learning so apologize. Explain ti me how can i add this for premarket under watchlist or i use as a scan? this script works great during when market opens.
 
S

Sonny

Active member
VIP
@Vimal Mittal

These columns can only be used during market hours. During premarket, I only use Mark % Change, Mark, and Volume as my columns.
 
V

Vimal Mittal

Member
But do you use relative volume in premarket? I am looking for relative volume not average volume in premarket.

Is this script to put it on chart as a study or for scan or for watchlist? The reason i ask is i am getting an error if i use for watchlist column.
Thanks. Apology for my lack of knowledge.

I apologize but is it possible to use for premarket? I like it this study for intraday it works really well.
 
S

Sonny

Active member
VIP
@Vimal Mittal

Try the new revised version of the chart labels near the top of the page. This will show premarket stats and then change to intraday stats after 9:30. If you want volume, just add "Volume" as a column to your premarket scan. I only use Mark % Change, Mark, and Volume as columns in my premarket scan.
 
S

Sonny

Active member
VIP
@soary

I fixed the errors you had in your code. Just add this code to the bottom of the revised big code I posted near the top of page 3:

Code:
#Volume Today
AddLabel (L1 < 5, "VT: " + today, CreateColor(206, 177, 128));
AddLabel (L1 between 4.5 and 5.5, "VT: " + Round((today / 1000), 0) + "K", CreateColor(206, 177, 128));
AddLabel (L1 > 5, "VT: " + Round((today / 1000000), 1) + "M", CreateColor(206, 177, 128));

#Yest Vol
def YV = volume(period=AP)[1];
def L2 = RoundDown(Lg(YV), 0);
AddLabel (L2 < 5, "YV: " + YV, CreateColor(30,182,228));
AddLabel (L2 between 4.5 and 5.5, "YV: " + Round((YV / 1000), 0) + "K", CreateColor(30,182,228));
AddLabel (L2 > 5, "YV: " + Round((YV / 1000000), 1) + "M", CreateColor(30,182,228));

#Dif bet yest volume and today
def DV2 = today - YV;
def L3 = RoundDown(Lg(DV2), 0);
AddLabel (L3 < 5, "DV2: " + DV2, CreateColor(208,209,238));
AddLabel (L3 between 4.5 and 5.5, "DV2: " + Round((DV2 / 1000), 0) + "K", CreateColor(208,209,238));
AddLabel (L3 > 5, "DV2: " + Round((DV2/ 1000000), 1) + "M", CreateColor(208,209,238));

#Relative Volume 2d
def R2 = Average(volume(period = AP)[1], 2);
def RV2 = today/R2;
Addlabel(1, “RV2: "+ Round(RV2,1), createcolor(254,216,177));

#Relative Volume 100d
def R3 = Average(volume(period = AV)[1], 100);
def RV3 = today/R3;
Addlabel(1, "RV100: "+ Round(RV3,1), createcolor(178,255,102));

#Difference between AV and today's volume
def AVD = today-R3;
def L4 = RoundDown(Lg(AVD),0);
AddLabel (L4 < 5, "AVD: " + AVD, CreateColor(206, 177, 128));
AddLabel (L4 between 4.5 and 5.5, "AVD: " + Round((AVD / 1000), 0) + "K", CreateColor(206, 177, 128));
AddLabel (L4 > 5, "AVD: " + Round((AVD / 1000000), 1) + "M", CreateColor(206, 177, 128));
 
Last edited:
Top