does AggregationPeriod work for volume?

Cre8able

New member
I'm trying to create an indicator that can use higher timeframes for some of my indicators. Everything works except a volume related indicator. I know you can use open, close, high, low so it seems to me that I should be able to use volume since that is the other key value for a bar. But it didn't seem to give me the results I was expecting. Anyone know if it's possible and I just missed something?


I did discover an unfortunate thing about AggregationPeriod. You cant bury it inside a function then use the function to reference historical data using open[1] type notation.

if you have a function:
def bob = average(close(period = AggregationPeriod.THREE_DAYS), 20)

you cant use:
def sally = bob - bob[1]

you have to make a:
def bob1 = average(close(period = AggregationPeriod.THREE_DAYS)[1], 20)

then sally = bob - bob1

kinda a pain, but that's how thinkscript thinks you should do it
 
Solution
This works for me:
Code:
declare lower;

def Data = GetValue(data = volume(period = AggregationPeriod.DAY), "dynamic offset" = 0);

plot vol = data;

Generally speaking, it is best to make calls and define variables as containers once and then use the container, rather than using the call to close() or whatever inside another function.

In your code, you have this:
Code:
def bob = average(close(period = AggregationPeriod.THREE_DAYS), 20)
when the cleaner way is to do this:
Code:
def c = close(period = AggregationPeriod.THREE_DAYS);
def bob = average(c, 20)
this also allows you not to make two calls to the agg period when you define bob1:
Code:
def c = close(period = AggregationPeriod.THREE_DAYS);
def bob = average(c, 20);
def bob1 =...
This works for me:
Code:
declare lower;

def Data = GetValue(data = volume(period = AggregationPeriod.DAY), "dynamic offset" = 0);

plot vol = data;

Generally speaking, it is best to make calls and define variables as containers once and then use the container, rather than using the call to close() or whatever inside another function.

In your code, you have this:
Code:
def bob = average(close(period = AggregationPeriod.THREE_DAYS), 20)
when the cleaner way is to do this:
Code:
def c = close(period = AggregationPeriod.THREE_DAYS);
def bob = average(c, 20)
this also allows you not to make two calls to the agg period when you define bob1:
Code:
def c = close(period = AggregationPeriod.THREE_DAYS);
def bob = average(c, 20);
def bob1 = average(c[1], 20);

Hope that helps,
mashume
 
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
536 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