Count 15 bars of Volume

tatl

Member
Found this code:
Ruby:
declare lower;
#COUNT OF THE CUMULATIVE OF THE TOTAL NUMBER OF GREEN BARS (CLOSE>OPEN) FROM XYZ BARS AGO
#(COUNT CUMULATIVE TOTAL OF GREEN BARS FROM THE LAST / PAST XYZ BARS)
# By XeoNoX via Usethinkscript.com
input barsago = 15;
def var =close>open;
def count = Sum(var, barsago);
AddLabel (yes, "COUNT " +  (count)  );
https://usethinkscript.com/threads/...tire-chart-or-specified-time.5496/#post-51741

If i wanted to use "volume" in place of var, and have the count reset to 0 each 15 bars and begin again, what would that look like?

i'm having trouble figuring out how to reset the count
 
Last edited by a moderator:
Found this code:
Ruby:
declare lower;
#COUNT OF THE CUMULATIVE OF THE TOTAL NUMBER OF GREEN BARS (CLOSE>OPEN) FROM XYZ BARS AGO
#(COUNT CUMULATIVE TOTAL OF GREEN BARS FROM THE LAST / PAST XYZ BARS)
# By XeoNoX via Usethinkscript.com
input barsago = 15;
def var =close>open;
def count = Sum(var, barsago);
AddLabel (yes, "COUNT " +  (count)  );
https://usethinkscript.com/threads/...tire-chart-or-specified-time.5496/#post-51741

If i wanted to use "volume" in place of var, and have the count reset to 0 each 15 bars and begin again, what would that look like?

i'm having trouble figuring out how to reset the count

i don't know what you want to do with volume? add up 15 bars of volume?

here are 2 ways to have a resetting counter

Code:
input max = 15;

input start = 0930;
def cnt = if secondsfromTime(start) == 0 then 1
 else if cnt[1] == max then 1
 else cnt[1] + 1;

addchartbubble(1, low, cnt, color.yellow, no);



# ver2
def bn = barnumber();
def cnt2 = if (bn % max) == 0 then 1
else cnt2[1] + 1;

addchartbubble(1, low, cnt, color.cyan, no);
#
 

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

i don't know what you want to do with volume? add up 15 bars of volume?

here are 2 ways to have a resetting counter

Code:
input max = 15;

input start = 0930;
def cnt = if secondsfromTime(start) == 0 then 1
 else if cnt[1] == max then 1
 else cnt[1] + 1;

addchartbubble(1, low, cnt, color.yellow, no);



# ver2
def bn = barnumber();
def cnt2 = if (bn % max) == 0 then 1
else cnt2[1] + 1;

addchartbubble(1, low, cnt, color.cyan, no);
#
thanks immensely. what does the (bn % max) do here? i'm not familiar with using % in thinkscript. earlier i also saw someone using "!" both alone and before a word like !var and i have no idea what that does.

^feel free to not answer if its too much effort bcuz my real question is this:

regarding the volume:

what i'm really trying to do is make the bars "slow down" in a sense, or "package" 15bars into One bar that prints their sum. i'm using a 1-tick chart for reasons i dont wanna explain at length, but i'm trying to get a histogram indicator from the 1-tick chart to basically not print every tick, but build a cumulative bar that's 15-ticks long and and repeat. so the bar would be changing height for 15 ticks, summing the volumes for example, then stop and the next bar would begin printing, summing the volumes. is this possible?
 
thanks immensely. what does the (bn % max) do here? i'm not familiar with using % in thinkscript. earlier i also saw someone using "!" both alone and before a word like !var and i have no idea what that does.

^feel free to not answer if its too much effort bcuz my real question is this:

regarding the volume:

what i'm really trying to do is make the bars "slow down" in a sense, or "package" 15bars into One bar that prints their sum. i'm using a 1-tick chart for reasons i dont wanna explain at length, but i'm trying to get a histogram indicator from the 1-tick chart to basically not print every tick, but build a cumulative bar that's 15-ticks long and and repeat. so the bar would be changing height for 15 ticks, summing the volumes for example, then stop and the next bar would begin printing, summing the volumes. is this possible?

% as an operator finds a remainder
https://tlc.thinkorswim.com/center/reference/thinkScript/Operators/Arithmetic

input max = 15;
def cnt2 = if (bn % max) == 0 then 1

every 15th barnumber will be divisible by max(15) and the remainder will be 0.
so cnt2 will be true on every 15th bar.

sorry, i am not familiar with tick charts, so not sure what can be done with them
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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