Daily Sum of Volume Question

xfitzz

New member
Hi all,

I'm looking for code that will plot the daily sum of a certain day only. I've played around with the TotalSum function, but it obviously changes if I go above Today's time frame. Anyway I can limit it to just today's total sum from 9:30 to 4:00?
 

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

Here you go... I dug around and found a study I wrote a couple weeks ago and forgot about... It probably won't exclude extended trading hours...

Ruby:
#Todays_Volume_Label
#Created 2020-09-09 by rad14733
#
input showTodaysVolumeLabel = yes;
def todaysVolume = volume(period = "DAY");
AddLabel(showTodaysVolumeLabel, "Todays Volume: " + todaysVolume, Color.WHITE);
 
@rad14733 One last question - maybe you can help me here as well.

Here is the code from a previous thread. I've got my comments below.

Code:
declare lower;
input LookBack = 20;
def nMinutes = GetAggregationPeriod() / 60000;
def nBars = RoundUp(390 / nMinutes, 0);

def pvSum = fold idx = 1 to LookBack + 1 with a=0 do a + GetValue(volume, idx * nBars, LookBack * nBars);

def pvAvg = pvSum / LookBack;
def VolPct = (volume / pvAvg) * 100;

plot avgLine = 100;
avgLine.SetDefaultColor(Color.GRAY);
avgLine.SetStyle(Curve.LONG_DASH);

def lastUp = if IsNaN(lastUp[1]) then 0 else if (close > open) then VolPct else lastUp[1];
def lastDn = if IsNaN(lastDn[1]) then 0 else if (close < open) then VolPct else lastDn[1];

plot Vol = VolPct;
Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.DefineColor("Bullish", Color.CYAN);
Vol.DefineColor("Bullish Smaller", CreateColor(0, 128, 128));
Vol.DefineColor("Bearish", Color.MAGENTA);
Vol.DefineColor("Bearish Smaller", CreateColor(128, 0, 128));
Vol.AssignValueColor(if (close > open) and (VolPct > lastUp[1]) then Vol.Color("bullish" ) else if close > open then Vol.Color("bullish smaller" ) else if close < open and VolPct > lastDn[1] then Vol.Color("bearish" ) else Vol.Color("bearish smaller" ));
Vol.SetLineWeight(3);

#My comments/question: is there a way to get the daily sum (as in today's daily sum only that resets each morning at 9:30 AM at new market open) for the plot Vol?

Thank you!
 
Last edited by a moderator:
@mashume you may be able to tell me if this is possible as well. Thank you!
Not at my station with ToS, but perhaps something like this:

Code:
def pvSum =
    if SecondsFromTime(0930) >= 0 then
        fold idx = 1 to LookBack + 1
            with a=0
            do a + GetValue(volume, idx * nBars, LookBack * nBars)
    else
        0;

You don't, of course, need that much whitespace... it just makes it easier for me to think in a text editor. :)

-mashume
 
Not at my station with ToS, but perhaps something like this:

Code:
def pvSum =
    if SecondsFromTime(0930) >= 0 then
        fold idx = 1 to LookBack + 1
            with a=0
            do a + GetValue(volume, idx * nBars, LookBack * nBars)
    else
        0;

You don't, of course, need that much whitespace... it just makes it easier for me to think in a text editor. :)

-mashume
Thanks for the help! I think this is going down the correct path.

qMwKlCU.png


See image attached. These are the values from the time based volume. At 9:48 it was 0.89. Is there a way that at 9:30 it starts at 0.00 and collects that daily running sum? Thanks again @mashume !
 
@mashume Unfortunately no. Most values range around 1. If its a spike in volume it can range up to 4 or 5 or even as high as 10.

I'll throw out the values (1 min) of Tesla here for the first 5 minutes:
9:30 - 3.92
9:31 - 2.30
9:32 - 2.00
9:33 - 2.53
9:34 - 1.61

So through the first 5 minutes our sum is 12.36. With the code above it would add actual volume, which is hundreds of thousands of shares. I'm specifically looking at the plot for the the daily sum starting a 0 each day. Hope this makes sense. Sorry for any confusion.

@mashume sorry to bother! Was curious if you saw this last comment and if this is even possible.
 
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
428 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