How to calculate Volume from the open ?

Answer Question

Hello Pete,


I hope all is well. I have been working on some code that calculates the total volume from the 9:30am open. However, the code gives me the total volume on the day. How does one modify the code to only calculate from 9:30am est.




Volume from open


def totaldayvolume = volume(period = “DAY”);

plot data = if IsNaN(close[-1]) then totaldayvolume else Double.NaN;


Marked as spam
Posted by (Questions: 23, Answers: 63)
Asked on September 14, 2019 7:13 am
I have no idea the difference between what you are requesting and what the code you posted already does.
( at September 14, 2019 7:55 am)
the code above includes premarket volume, I would like to exclude the premarket volume from the total volume
( at September 14, 2019 8:12 am)
No, it does not include extended session hours. Add the volume candles on the intraday and compare to the daily. The don't match but it is NOT because the daily chart includes extended hours (even when including extended session data they totals do not match). I suspect it includes trading volume from the dark pools, something not included on intraday charts. I have submitted a request to TDA Support asking to explain this in detail.
( at September 14, 2019 11:22 am)


Private answer

We already have a solution for this here:

Simply adjust the start and end time to facilitate the time period you need.

Edit: There was a question as to why the volume taken from the daily time frame was not the same as the volume computed from the intraday data. The author of the post stated this was because the daily data included extended hours volume. Which I denied and said it did not. I decided this is very important for our viewers so I contacted TDA support to ask for clarification. Below is the text of their response.

Hello Pete,

Thank you for reaching out, this is a good question. I checked with our quote team and will can be differences between intraday and Daily volume. Daily volume is going to include late prints (adjustments from the exchanges shortly after the close). In addition intraday charts do not account for odd lots (lots less than 100 shares).

I hope this helps to clear things up, please let us know if you need anything more.

Warm Regards,

Michael N

Trader Support, Trader Services

Marked as spam
Posted by (Questions: 37, Answers: 2985)
Answered on September 14, 2019 11:24 am
I updated my answer to include the response I received from TDA support asking them to explain why the volume data from Daily and Intraday time frames are not the same.
( at September 17, 2019 1:37 pm)
So we can calculate the total volume from the 9:30 am open candle to the current close candle?
( at September 25, 2019 5:13 am)
Yes, by using the code from the previous post that I linked to in my answer.
( at September 25, 2019 8:47 am)
amazing works great
( at September 25, 2019 6:26 pm)