scan or column for yesterday's volume

chrisj1881

New member
Hello. I have been trying to find a way to get just a -1 day period for volume . I usually have time to scan and chart in the mornings pre market but the volume after midnight gets reset to 0 or shows NA and skews the data a bit. Does anyone know a way to get yesterdays volume either in a scan or a watchlist column?
 
@chrisj1881 You can get yesterdays Volume by setting your scan condition to Day timeframe and scan for volume[1]... Essentially using an offset/displace of 1...
Thanks Rad, I did create a watchlist column with that script you mentioned but it doesn't show it correctly it shows like this. looking at AAPL volume today TOS column = (99,890,800) custom yesterday's volume column = (1.05575458E8) Do you know if there's a way to change the numeric to show like the TOS volume column?
 
@chrisj1881 Try this...

Ruby:
plot vol = volume[1];
AddLabel(yes, vol, Color.BLACK);
AssignBackgroundColor(if vol > volume then Color.GREEN else Color.RED);
I was able to incorporate it into a column. Now I just need to figure out if I change [1] to [30] or [22] would it generate volume for previous 30 / 22 days. Please advise, thanks!
 
I was able to incorporate it into a column. Now I just need to figure out if I change [1] to [30] or [22] would it generate volume for previous 30 / 22 days. Please advise, thanks!

No... The [1] is an index to a specific bar in the past... Therefore, [30] would provide the volume for the bar from 30 bars ago... You could use Sum(volume, 30), however, to get the total volume of the past 30 bars... OR...

Ruby:
def bars = 30;
plot vol = Sum(volume, bars);
AddLabel(yes, vol, Color.BLACK);
AssignBackgroundColor(Color.YELLOW);

Note that you cannot change the color when using the sum of volume, as in my previous example, as it would be inaccurate...
 
No... The [1] is an index to a specific bar in the past... Therefore, [30] would provide the volume for the bar from 30 bars ago... You could use Sum(volume, 30), however, to get the total volume of the past 30 bars... OR...

Ruby:
def bars = 30;
plot vol = Sum(volume, bars);
AddLabel(yes, vol, Color.BLACK);
AssignBackgroundColor(Color.YELLOW);

Note that you cannot change the color when using the sum of volume, as in my previous example, as it would be inaccurate...
Thanks @rad14733 as always I appreciate your patience and feedback. I will try (sum, volume 30), disable assign background color, & keep aggregation to d. Will check out in the pm morning. Thanks

Edit: didn't work for 30d or 22d average volume.
 
Last edited:
Thanks @rad14733 as always I appreciate your patience and feedback. I will try (sum, volume 30), disable assign background color, & keep aggregation to d. Will check out in the pm morning. Thanks

Edit: didn't work for 30d or 22d average volume.
Ahhh... If you want the average then use Average(volume, 30)... However, that wasn't how your last request was phrased...

mansor said:
I was able to incorporate it into a column. Now I just need to figure out if I change [1] to [30] or [22] would it generate volume for previous 30 / 22 days. Please advise, thanks!
 
@rad14733
I was able to set average (voume, 30)
plot vol = Average(volume, 30);
AddLabel(yes, vol, Color.BLACK);
AssignBackgroundColor(Color.YELLOW);

and aggregation period is set to D.

When I check out xbio ticker & insert it on my graph, I see horserider's volume labels reads 30D Avg: 820,000 & on the column that I have made using above script.. it reads 6,281,157. Could you advise how I can have horserider's label (30D Average) switched into a column. Thanks again for genuine effort & guiding me.

Edit: I had to replace "def" with "plot"

#Volume Data

def volLast30DayAvg = (volume(period = "DAY")[1] + volume(period = "DAY")[2] + volume(period = "DAY")[3] + volume(period = "DAY")[4] + volume(period = "DAY")[5] + volume(period = "DAY")[6] + volume(period = "DAY")[7] + volume(period = "DAY")[8] + volume(period = "DAY")[9] + volume(period = "DAY")[10] + volume(period = "DAY")[11] + volume(period = "DAY")[12] + volume(period = "DAY")[13] + volume(period = "DAY")[14] + volume(period = "DAY")[15] + volume(period = "DAY")[16] + volume(period = "DAY")[17] + volume(period = "DAY")[18] + volume(period = "DAY")[19] + volume(period = "DAY")[20] + volume(period = "DAY")[21] + volume(period = "DAY")[22] + volume(period = "DAY")[23] + volume(period = "DAY")[24] + volume(period = "DAY")[25] + volume(period = "DAY")[26] + volume(period = "DAY")[27] + volume(period = "DAY")[28] + volume(period = "DAY")[29] + volume(period = "DAY")[30]) / 30;
def today = volume(period = "DAY");

It provides same data/numbers of 30D average volume.

Edit II: upon reviewing the numbers (30D average volume) are showing up in a manner of value instead of what default volume column shows in the scanner. Eg: xbio 30DAV is showing 820545.07 instead of 820,545. Could you advise how to round them please
 
Last edited:

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