Hi, need help with 1) finding volume traded for the first 5minutes after open for today and 2)the average of this volume for the past 20 days.

dash

New member
VIP
Hi, need help with 1) finding volume traded for the first 5minutes after open for today and 2)the average of this volume for the past 20 days.

I was able to find 1) briefly through
def start = SecondsFromTime(0930);
def end = SecondsTillTime(0935);
def first5min = if start >=0 and end >0 then 1 else 0;
def vol = if first5min and !first5min[1] then volume else if first5min then vol[1]+volume else vol[1];

Now I am stuck on 2) and not sure how to go about finding the volume of first 5min traded for yesterday and that of the day before yesterday..etc to take the average of this 5min volume traded for the past 20 days. Please help.
 
Solution
Hi, need help with 1) finding volume traded for the first 5minutes after open for today and 2)the average of this volume for the past 20 days.

I was able to find 1) briefly through
def start = SecondsFromTime(0930);
def end = SecondsTillTime(0935);
def first5min = if start >=0 and end >0 then 1 else 0;
def vol = if first5min and !first5min[1] then volume else if first5min then vol[1]+volume else vol[1];

Now I am stuck on 2) and not sure how to go about finding the volume of first 5min traded for yesterday and that of the day before yesterday..etc to take the average of this 5min volume traded for the past 20 days. Please help.
This seems to work. Just make sure you have 20 days of bars on your chart you are viewing.
Ruby:
...
Hi, need help with 1) finding volume traded for the first 5minutes after open for today and 2)the average of this volume for the past 20 days.

I was able to find 1) briefly through
def start = SecondsFromTime(0930);
def end = SecondsTillTime(0935);
def first5min = if start >=0 and end >0 then 1 else 0;
def vol = if first5min and !first5min[1] then volume else if first5min then vol[1]+volume else vol[1];

Now I am stuck on 2) and not sure how to go about finding the volume of first 5min traded for yesterday and that of the day before yesterday..etc to take the average of this 5min volume traded for the past 20 days. Please help.
This seems to work. Just make sure you have 20 days of bars on your chart you are viewing.
Ruby:
def start = SecondsFromTime(0930);
def end   = SecondsTillTime(0935);
def first5min = if start >= 0 and end > 0 then 1 else 0;
def vol       = if first5min and !first5min[1] then volume else if first5min then vol[1] + volume else vol[1];

def ymd = GetYYYYMMDD();
def x   = if Between(ymd, ymd[20], ymd) and first5min then x[1] + volume else x[1];

AddLabel(1, "Today Vol: " + vol, if vol > (x - vol) / 20 then Color.GREEN else Color.RED);
AddLabel(1, "20D Avg Vol: " + (x - vol) / 20, if vol > (x - vol) / 20 then Color.GREEN else Color.RED);
 
Solution

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

This seems to work. Just make sure you have 20 days of bars on your chart you are viewing.
I get different average numbers for different time frames (1min vs 5min vs 60min). Which timeframe do you recommend to use this one? The average volume number increases as I increase timeframe.
 
I get different average numbers for different time frames (1min vs 5min vs 60min). Which timeframe do you recommend to use this one? The average volume number increases as I increase timeframe.
Never mind. I was able to get the same average number by increasing "Time Interval" from 5D5Min to 30D5Min which shares the same Time Interval count as my 60min timeframe chart. Thank you.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
340 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