Compare volumes of today and yesterday between open and current times

GaiSensei

New member
Hi all,

I'm looking to create a formula that compares today's volume to yesterday's volume, between 9am and the current time for each day.

Formula should be something like "Yesterday's Volume (between 9am and Current Time) - 24 hours, divided by Today's volume (between 9am and current time)". Output would simply be a percentage, in a box/label, stating how today's volume compares to yesterday's volume, at this same time.

Cannot find a single thing online about a study like this so here I am trying to make it myself! Thanks for any help.
 
Solution
Hi all,

I'm looking to create a formula that compares today's volume to yesterday's volume, between 9am and the current time for each day.

Formula should be something like "Yesterday's Volume (between 9am and Current Time) - 24 hours, divided by Today's volume (between 9am and current time)". Output would simply be a percentage, in a box/label, stating how today's volume compares to yesterday's volume, at this same time.

Cannot find a single thing online about a study like this so here I am trying to make it myself! Thanks for any help.

Here is some code by Mobius that you might find helpful. It does not appear to work on timeframes outside normal trading hours as the aftermarket activity is sporadic. If you want the 9am...
Hi all,

I'm looking to create a formula that compares today's volume to yesterday's volume, between 9am and the current time for each day.

Formula should be something like "Yesterday's Volume (between 9am and Current Time) - 24 hours, divided by Today's volume (between 9am and current time)". Output would simply be a percentage, in a box/label, stating how today's volume compares to yesterday's volume, at this same time.

Cannot find a single thing online about a study like this so here I am trying to make it myself! Thanks for any help.

Here is some code by Mobius that you might find helpful. It does not appear to work on timeframes outside normal trading hours as the aftermarket activity is sporadic. If you want the 9am begin time, probably best used for 1hr timeframe charts.

It appears that the prior day matching period only plots after the close of the associated current timeframe bar, which appears to actively accumulate during the bar.

This study will load in the volume panel. If you do not have show volume subgraph checked, the label will not show, unless you move the indicator to one of the other chart panes.

Ruby:
# Comparison of Today's Volume at bar and Volume at time.
# Mobius
# V01.11.02.2017
input begin = 0930;
input end   = 1600;
def v = volume;
def bar = barNumber();
def xBar = if secondstilltime(begin)[1]>0 and secondsTillTime(begin) == 0
                     then bar
                     else xBar[1];
def pxBar = if xBar != xBar[1]
                         then xBar[1]
                         else pxBar[1];
def zxBar = if SecondsFromTime(begin) >= 0 and
                       SecondsTillTime(end) > 1
                    then 0
                    else if SecondsTillTime(end) == 0
                        then bar
                        else zxBar[1];
def pzxBar = if zxBar != zxBar[1]
                        then zxBar[1]
                        else pzxBar[1];
def pxBars = if bar == xBar
                   then pxBar
                   else if bar >= xBar
                        then pxBars[1] + 1
                        else pxBars[1];
def length = bar - (pxBars-1);
def RelVol = if bar >= xBar
                    then getValue(v, length)
                    else 0;
def pVol = if bar == xBar
                    then 0
                    else if bar > xBar
                         then pVol[1] + RelVol
                         else pVol[1];
def tVol = if SecondsTillTime(begin) == 0
                then v
                else if SecondsFromTime(begin) > 0  and SecondsTillTime(end) >= 0
                then compoundValue(1, tVol[1] + v, v)
                else tVol[1];
addlabel(1, "yesterdays volume at bar = " + RelVol +
          "  yesterdays volume = " + pVol +
          "  todays volume = " + tVol,
          if tVol > pVol
          then color.green
          else color.red);
# End Code Previous Days Volume Comparison
 
Solution

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