I took the screenshot when I made this post, which was around 9am EST. But I scanned for stocks with 1million shares traded and only TSLA showed until nearly open. Used the standard stock hacker.
So as I stated previously, yes, perhaps the ToS scanner AND my other software count the previous day post market data and premarket data for the current day? Is fo, can you make it show that number to check?
Tomorrow if you have a chance please do a premarket scan for stocks with 1mil volume (standard stock hacker) and see what shows up vs. what this says.
Thanks for the help here too!
To add on to that, How can I modify the script to track BUY volume > SELL volume?How could I modify this script to search for stocks with certain required premarket volume for today or for X days in the past?
The ToS data feeds do not provide BUY volume or SELL volume, only total volume.To add on to that, How can I modify the script to track BUY volume > SELL volume?
Give this a shot. Many volume studies I've used in the past use this to determine buy/sell volume. One of the things I will be doing in the near future is breaking up volume based on the bid/ask. In the meantime, try this.To add on to that, How can I modify the script to track BUY volume > SELL volume?
And here is a simple scanner using above code.
Code:Def requiredVolume = 100000; def premarketStart = 0400; def premarketEnd = 0930; def premarketVolume = if getday() != Getlastday() then 0 else if PremarketVolume[1] == 0 then volume else if secondsFromtime(premarketStart) >= 0 and secondsFromTime(premarketEnd) < 0 then volume+premarketVolume[1] else PremarketVolume[1]; Plot PremarketV = if premarketVolume >=requiredVolume then 1 else 0;
Are you wanting an average or are you just wanting to see what the premarket volume was as an example 2 days ago?How could I modify this script to search for stocks with certain required premarket volume for today or for X days in the past?
The latter.Are you wanting an average or are you just wanting to see what the premarket volume was as an example 2 days ago?
16446[/ATTACH]']Here you go
Ruby:# Box Volume Stats # Version 1.2 # Created by: Enigma # Created: 05/18/17 # Modified by: Surya Kiran C ## Included rVolume label and Changed length as input. ## Additionally Pre-Market, 1Hr Volume, AfterHour Volume labels are added. declare on_volume; input length = 30; input ShowDayAvg = yes; input ShowTodayVolume = yes; input ShowPercentOfDayAvg = yes; input UnusualVolumePercent = 200; input ShowBarAvg = yes; input ShowCurrentBar = yes; input PreMktVol = yes; input RTH1HrVol = yes; input PostMktVol = yes; def VolDayAvg = (fold index = 1 to length + 1 with Avg = 0 do (Avg + volume(period = "DAY")[index])) / length; def AvgBars = (fold index2 = 1 to length + 1 with Bar = 0 do (Bar + volume[index2])) / length; def Today = volume(period = "DAY"); def PercentOfDayAvg = Round((Today / VolDayAvg) * 100, 0); def CurVol = volume; def offset = 1; def ADV = Average(volume, length)[offset]; def rVol = volume / ADV; # Labels #if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if 1HrRTHVol then 1 else 0, AddLabel(ShowDayAvg, length + "Day Avg: " + Round(VolDayAvg, 0) + " ", Color.LIGHT_GRAY); AddLabel(ShowTodayVolume, "Today: " + Today + " ", (if PercentOfDayAvg >= UnusualVolumePercent then Color.GREEN else if PercentOfDayAvg >= 100 then Color.ORANGE else Color.LIGHT_GRAY)); AddLabel(ShowPercentOfDayAvg, PercentOfDayAvg + "%", (if PercentOfDayAvg >= UnusualVolumePercent then Color.GREEN else if PercentOfDayAvg >= 100 then Color.ORANGE else Color.WHITE) ); AddLabel(ShowBarAvg, "Avg" + length + "Bars: " + Round(AvgBars, 0) + " ", Color.LIGHT_GRAY); AddLabel(ShowCurrentBar, "Cur Bar: " + CurVol + " ", (if CurVol >= AvgBars then Color.GREEN else Color.ORANGE)); AddLabel(yes, "rVol :" + Round(rVol, 2)); #AddLabel(yes, "ADV :" + ADV); #AddLabel(yes, asPercent(rVol)); # remove "#" infront of Addlabels to select prefer choice #AssignPriceColor(if rVol >= 1 then color.dark_red else if rVol <=.5 then Color.black else color.Gray); #Pre, 1Hr RTH, AfterHours Volumes. ##if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if PreMktVol then 1 else 0 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 = " + PreVolMins + " ", Color.Gray); # End Volume PreMarket input RTH1HrstartTime = 0930; input RTH1HrendTime = 1029; def RTH1Hr = SecondsFromTime(RTH1HrstartTime) >= 0 and SecondsTillTime(RTH1HrendTime) >= 0; def RTH1HrMins = if RTH1Hr and !RTH1Hr[1] then volume else if RTH1Hr then RTH1HrMins[1] + volume else RTH1HrMins[1]; AddLabel(if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if RTH1HrVol then 1 else 0, "RTH1HrVol = " + RTH1HrMins + " ", Color.Gray); #End Volume RTH First 60 Mins 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 = " + PostVolMins + " ", Color.Gray); # End Volume PostMarket
Is there any way to get the Average premarket volume and average premarket volume vs today's percent difference?Updated Code at 6:44 PM EST
Make sure you have the watchlist column on 1 minute and extended hours box checked (as I know that works). Another reason it could have been wrong is because if there is no premarket volume on the current day, it would have showed you yesterdays premarket volume (or whatever day previously had premarket volume). That's never an issue for me because I also have the default volume column next to my premarket volume and if they are different (during premarket only), I know it's showing the previous day's data. I did modify it so it should now show 0 if there is no premarket volume.
Code:def PremarketVolume = if getday() != Getlastday() then 0 else If secondsFromTime(0400) >= 0 and SecondsFromTime(0930) < 0 then volume+PremarketVolume[1] else PremarketVolume[1]; def VolumeR = If SecondsFromTime(0400) >= 0 and SecondsFromTime(0930) < 0 then Volumer[1]+Volume else 0; Plot PremarketV = If secondsFromTime(0400) >= 0 and SecondsFromTime(0930) < 0 then VolumeR else PremarketVolume;
Hi Wiinii - Sorry for the late reply. I actually already have something very similar to what you're asking (Relative PM volume is bottom-most chart. There was not a lot of time put into it, but here's the code:Is there any way to get the Average premarket volume and average premarket volume vs today's percent difference?
Declare Lower;
Declare zerobase;
def Day0PMVol = If getday() <> GetDay()[1] then If SecondsFromTime(0930) < 0 then volume else 0 else If secondsFromTime(0400) >= 0 and SecondsFromTime(0930) < 0 then Volume+Day0PMVol[1] else Day0PMVol[1];
plot pmvolplotted = If secondsFromTime(0400) >= 0 and SecondsFromTime(0930) < 0 then Day0PMVol else Double.nan;
pmvolplotted.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Def PmBack1Day = If GetDay() <> GetDay()[1] then Day0PMVol[1] else PmBack1Day[1];
Def PMBack2Day = If GetDay() <> GetDay()[1] then PmBack1Day[1] else PmBack2Day[1];
Def PmBack3Day = If GetDay() <> GetDay()[1] then PmBack2Day[1] else PmBack3Day[1];
Def PMBack4Day = If GetDay() <> GetDay()[1] then PmBack3Day[1] else PmBack4Day[1];
Def PmBack5Day = If GetDay() <> GetDay()[1] then PmBack4Day[1] else PmBack5Day[1];
Def PMBack6Day = If GetDay() <> GetDay()[1] then PmBack5Day[1] else PmBack6Day[1];
Def PmBack7Day = If GetDay() <> GetDay()[1] then PmBack6Day[1] else PmBack7Day[1];
Def PMBack8Day = If GetDay() <> GetDay()[1] then PmBack7Day[1] else PmBack8Day[1];
Def PmBack9Day = If GetDay() <> GetDay()[1] then PmBack8Day[1] else PmBack9Day[1];
Def PMBack10Day = If GetDay() <> GetDay()[1] then PmBack9Day[1] else PmBack10Day[1];
Def PMAvgVol = (PmBack1Day + PmBack2Day + PmBack3Day + PmBack4Day + PmBack5Day + PmBack6Day + PmBack7Day + PmBack8Day + PmBack9Day + PmBack10Day)/10;
plot AvgPmVol = If secondsFromTime(0400) >= 0 and SecondsFromTime(0930) < 0 then PMAvgVol else Double.nan;
AvgPmVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
AddLabel(1,"Average:" + PmAvgVol + "|" + "Today:" + Day0PMVol + "|" + "Relative:" + (Day0PMVol/PmAvgVol)*100 + "%");
Hi Wiinii - Sorry for the late reply. I actually already have something very similar to what you're asking (Relative PM volume is bottom-most chart. There was not a lot of time put into it, but here's the code:
Code:Declare Lower; Declare zerobase; def Day0PMVol = If getday() <> GetDay()[1] then If SecondsFromTime(0930) < 0 then volume else 0 else If secondsFromTime(0400) >= 0 and SecondsFromTime(0930) < 0 then Volume+Day0PMVol[1] else Day0PMVol[1]; plot pmvolplotted = If secondsFromTime(0400) >= 0 and SecondsFromTime(0930) < 0 then Day0PMVol else Double.nan; pmvolplotted.SetPaintingStrategy(PaintingStrategy.HISTOGRAM); Def PmBack1Day = If GetDay() <> GetDay()[1] then Day0PMVol[1] else PmBack1Day[1]; Def PMBack2Day = If GetDay() <> GetDay()[1] then PmBack1Day[1] else PmBack2Day[1]; Def PmBack3Day = If GetDay() <> GetDay()[1] then PmBack2Day[1] else PmBack3Day[1]; Def PMBack4Day = If GetDay() <> GetDay()[1] then PmBack3Day[1] else PmBack4Day[1]; Def PmBack5Day = If GetDay() <> GetDay()[1] then PmBack4Day[1] else PmBack5Day[1]; Def PMBack6Day = If GetDay() <> GetDay()[1] then PmBack5Day[1] else PmBack6Day[1]; Def PmBack7Day = If GetDay() <> GetDay()[1] then PmBack6Day[1] else PmBack7Day[1]; Def PMBack8Day = If GetDay() <> GetDay()[1] then PmBack7Day[1] else PmBack8Day[1]; Def PmBack9Day = If GetDay() <> GetDay()[1] then PmBack8Day[1] else PmBack9Day[1]; Def PMBack10Day = If GetDay() <> GetDay()[1] then PmBack9Day[1] else PmBack10Day[1]; Def PMAvgVol = (PmBack1Day + PmBack2Day + PmBack3Day + PmBack4Day + PmBack5Day + PmBack6Day + PmBack7Day + PmBack8Day + PmBack9Day + PmBack10Day)/10; plot AvgPmVol = If secondsFromTime(0400) >= 0 and SecondsFromTime(0930) < 0 then PMAvgVol else Double.nan; AvgPmVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM); AddLabel(1,"Average:" + PmAvgVol + "|" + "Today:" + Day0PMVol + "|" + "Relative:" + (Day0PMVol/PmAvgVol)*100 + "%");
Make sure you are displaying at least 10 days worth of data. With a little effort I can fix this but for me, there's no point.
#https://usethinkscript.com/threads/premarket-volume-for-thinkorswim.2383/post-116609
#Use 30min timeframe
Declare Lower;
Declare zerobase;
def Day0PMVol = If getday() <> GetDay()[1] then If SecondsFromTime(0930) < 0 then volume else 0 else If secondsFromTime(0400) >= 0 and SecondsFromTime(0930) < 0 then Volume+Day0PMVol[1] else Day0PMVol[1];
def pmvolplotted = If secondsFromTime(0400) >= 0 and SecondsFromTime(0930) < 0 then Day0PMVol else Double.nan;
Def PmBack1Day = If GetDay() <> GetDay()[1] then Day0PMVol[1] else PmBack1Day[1];
Def PMBack2Day = If GetDay() <> GetDay()[1] then PmBack1Day[1] else PmBack2Day[1];
Def PmBack3Day = If GetDay() <> GetDay()[1] then PmBack2Day[1] else PmBack3Day[1];
Def PMBack4Day = If GetDay() <> GetDay()[1] then PmBack3Day[1] else PmBack4Day[1];
Def PmBack5Day = If GetDay() <> GetDay()[1] then PmBack4Day[1] else PmBack5Day[1];
Def PMBack6Day = If GetDay() <> GetDay()[1] then PmBack5Day[1] else PmBack6Day[1];
Def PmBack7Day = If GetDay() <> GetDay()[1] then PmBack6Day[1] else PmBack7Day[1];
Def PMBack8Day = If GetDay() <> GetDay()[1] then PmBack7Day[1] else PmBack8Day[1];
Def PmBack9Day = If GetDay() <> GetDay()[1] then PmBack8Day[1] else PmBack9Day[1];
Def PMBack10Day = If GetDay() <> GetDay()[1] then PmBack9Day[1] else PmBack10Day[1];
Def PMAvgVol = (PmBack1Day + PmBack2Day + PmBack3Day + PmBack4Day + PmBack5Day + PmBack6Day + PmBack7Day + PmBack8Day + PmBack9Day + PmBack10Day)/10;
plot PMRVOL = Day0PMVol/PmAvgVol*100;
#https://usethinkscript.com/threads/premarket-volume-for-thinkorswim.2383/post-116609
#Use 30min timeframe
Declare Lower;
Declare zerobase;
def Day0PMVol = If getday() <> GetDay()[1] then If SecondsFromTime(0930) < 0 then volume else 0 else If secondsFromTime(0400) >= 0 and SecondsFromTime(0930) < 0 then Volume+Day0PMVol[1] else Day0PMVol[1];
def pmvolplotted = If secondsFromTime(0400) >= 0 and SecondsFromTime(0930) < 0 then Day0PMVol else Double.nan;
Def PmBack1Day = If GetDay() <> GetDay()[1] then Day0PMVol[1] else PmBack1Day[1];
Def PMBack2Day = If GetDay() <> GetDay()[1] then PmBack1Day[1] else PmBack2Day[1];
Def PmBack3Day = If GetDay() <> GetDay()[1] then PmBack2Day[1] else PmBack3Day[1];
Def PMBack4Day = If GetDay() <> GetDay()[1] then PmBack3Day[1] else PmBack4Day[1];
Def PmBack5Day = If GetDay() <> GetDay()[1] then PmBack4Day[1] else PmBack5Day[1];
Def PMBack6Day = If GetDay() <> GetDay()[1] then PmBack5Day[1] else PmBack6Day[1];
Def PmBack7Day = If GetDay() <> GetDay()[1] then PmBack6Day[1] else PmBack7Day[1];
Def PMBack8Day = If GetDay() <> GetDay()[1] then PmBack7Day[1] else PmBack8Day[1];
Def PmBack9Day = If GetDay() <> GetDay()[1] then PmBack8Day[1] else PmBack9Day[1];
Def PMBack10Day = If GetDay() <> GetDay()[1] then PmBack9Day[1] else PmBack10Day[1];
Def PMAvgVol = (PmBack1Day + PmBack2Day + PmBack3Day + PmBack4Day + PmBack5Day + PmBack6Day + PmBack7Day + PmBack8Day + PmBack9Day + PmBack10Day)/10;
plot PMRVOL = Day0PMVol/PmAvgVol*100;
It iterates through each day and assigns the volume to a variable and then divides it by 10. If there's not 10 days worth of data, it will divide the total pm volume by 10, regardless of the amount of days you're looking at.No need to apologize, you don't owe anybody anything bud. And thank you for sharing!
Premarket RVOL, exactly what I was looking for! We're obviously looking for stocks with volume in the morning.
But I'm not sure why this requires you to display 10 days on your chart to work (I'm a n00b to coding, forgive me), I was hoping to have PremktRvol as a watchlist column and something I could scan for. I'm just looking at it now, maybe I can figure it out, but if you already have that lemme know plz, and thanks again!
I wanted to give you a feedback. The number DOES NOT match with TOS Trade tab. Would you mind to double check?Thank you so much for response, Darkejo! I will give it a try and let you know.
I wanted to give you a feedback. The number DOES NOT match with TOS Trade tab. Would you mind to double check?Make sure you check "include extended hours".
Code:def PmV = if getday() != Getlastday() then Volume else if SecondsFromTime(0930) < 0 then volume+PmV[1] else PmV[1]; plot PmVplotted = PmV;
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
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.
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.