Bar Count.. every THREE bars

DoQtorNo

Member
VIP
Hello,

im looking to edit this bar counter to count every three bars. ex: 1 3 6 9 12 15 etc. I've tweaked every input to no avail, any assistance greatly appreciated.

input StartAt = 930;
input EndAt = 1615;
def active = secondsFromTime(StartAt) >= 0 and secondsFromTime(EndAt) < 0;
def count = if active and !active[1] then 1
else if !active and active[1] then double.NaN
else count[1]+1;
plot c = if count%2 <>0 then count else double.nan;
c.setPaintingStrategy(paintingStrategy.VALUES_BELOW);
 
Solution
Hello,

im looking to edit this bar counter to count every three bars. ex: 1 3 6 9 12 15 etc. I've tweaked every input to no avail, any assistance greatly appreciated.

input StartAt = 930;
input EndAt = 1615;
def active = secondsFromTime(StartAt) >= 0 and secondsFromTime(EndAt) < 0;
def count = if active and !active[1] then 1
else if !active and active[1] then double.NaN
else count[1]+1;
plot c = if count%2 <>0 then count else double.nan;
c.setPaintingStrategy(paintingStrategy.VALUES_BELOW);

changed a couple things,
..active = ...secondstillTime(EndAt) > 0; , till > 0

add a variable skip and set to 3
count will count as 1,2,0,1,2,0,..
..plot c = if count % skip == 0...
Hello,

im looking to edit this bar counter to count every three bars. ex: 1 3 6 9 12 15 etc. I've tweaked every input to no avail, any assistance greatly appreciated.

input StartAt = 930;
input EndAt = 1615;
def active = secondsFromTime(StartAt) >= 0 and secondsFromTime(EndAt) < 0;
def count = if active and !active[1] then 1
else if !active and active[1] then double.NaN
else count[1]+1;
plot c = if count%2 <>0 then count else double.nan;
c.setPaintingStrategy(paintingStrategy.VALUES_BELOW);

changed a couple things,
..active = ...secondstillTime(EndAt) > 0; , till > 0

add a variable skip and set to 3
count will count as 1,2,0,1,2,0,..
..plot c = if count % skip == 0 then count

the number 1 doesn't fit in with the other numbers, the spacing is different.
if you want to include 1, then remove the # from this line (after the plot)
# else if active and !active[1] then count


Code:
#bar_count_3
#https://usethinkscript.com/threads/bar-count-every-three-bars.19923/
#Bar Count.. every THREE bars

input StartAt = 930;
input EndAt = 1615;
def active = secondsFromTime(StartAt) >= 0 and secondstillTime(EndAt) > 0;
def count = if active and !active[1] then 1
 else if !active and active[1] then double.NaN
 else count[1]+1;

def skip = 3;
plot c = if count % skip == 0 then count
# else if active and !active[1] then count
 else double.nan;
c.setPaintingStrategy(paintingStrategy.VALUES_BELOW);
c.setdefaultcolor(color.white);


addchartbubble(0, low*0.999,
#active + "\n" +
#count + "\n" +
((count % skip) -1) + "\n" +
((count % skip) + 0) + "\n" +
((count % skip) + 1) + "\n"
, color.yellow, no);
#
 
Solution

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

thank you so much.

there are a few things i noticed maybe u can further assist with.

the numbering is 100% spot on however, number 3 is under bar 2 and the bar count doesnt reset each day via 5D:5M chart.

see attach
 

Attachments

  • Screenshot 2024-11-03 at 8.54.53 AM.png
    Screenshot 2024-11-03 at 8.54.53 AM.png
    116.8 KB · Views: 23

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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