Bar counter

stt31

New member
I can't upload quickly a picture to show, but I use this code (see at the bottom). It's a histogram from previous close to close.
My question goes as follow: I found this code: ⬇️
https://usethinkscript.com/threads/anybody-know-how-to-create-a-bar-counter-on-tos.4739/#post-47217

declare upper;
def GreenCandle = Close>Open;
def RedCandle = Close<Open;
def GreenCount = TOTALSUM(GreenCandle);
def RedCount = TOTALSUM(RedCandle);
AddLabel(yes, "GreenCandle: " + GreenCount, color.GREEN);
AddLabel(yes, "RedCandle: " + RedCount, color.R

Is there anyway someone can help me to use a similar count, but than with a counter how often market closes with let see +1% or -1%? Thanks a lot!
____________________________________________________________________________
PC to close code: ⬇️
input length = 1;

input price = close;

plot Diff = 100 * (close / close [length] - 1);

Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", CreateColor(51, 204, 0));
Diff.DefineColor("Positive and Down", CreateColor(51, 204, 0));
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
 
Last edited by a moderator:
Solution
I can't upload quickly a picture to show, but I use this code (see at the bottom). It's a histogram from previous close to close.
My question goes as follow: I found this code: ⬇️
https://usethinkscript.com/threads/anybody-know-how-to-create-a-bar-counter-on-tos.4739/#post-47217

declare upper;
def GreenCandle = Close>Open;
def RedCandle = Close<Open;
def GreenCount = TOTALSUM(GreenCandle);
def RedCount = TOTALSUM(RedCandle);
AddLabel(yes, "GreenCandle: " + GreenCount, color.GREEN);
AddLabel(yes, "RedCandle: " + RedCount, color.R

Is there anyway someone can help me to use a similar count, but than with a counter how often market closes with let see +1% or -1%? Thanks a lot...
I can't upload quickly a picture to show, but I use this code (see at the bottom). It's a histogram from previous close to close.
My question goes as follow: I found this code: ⬇️
https://usethinkscript.com/threads/anybody-know-how-to-create-a-bar-counter-on-tos.4739/#post-47217

declare upper;
def GreenCandle = Close>Open;
def RedCandle = Close<Open;
def GreenCount = TOTALSUM(GreenCandle);
def RedCount = TOTALSUM(RedCandle);
AddLabel(yes, "GreenCandle: " + GreenCount, color.GREEN);
AddLabel(yes, "RedCandle: " + RedCount, color.R

Is there anyway someone can help me to use a similar count, but than with a counter how often market closes with let see +1% or -1%? Thanks a lot!
____________________________________________________________________________
PC to close code: ⬇️
input length = 1;

input price = close;

plot Diff = 100 * (close / close [length] - 1);

Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", CreateColor(51, 204, 0));
Diff.DefineColor("Positive and Down", CreateColor(51, 204, 0));
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));

is this what you are looking for?
add this to the end of the histo code

Code:
def bn = barnumber();
input positive_percent = 1.0:
input negative_percent = -1.0:

def poscnt = if bn == 1 then 0
 else if diff >= positive_percent then poscnt[1] + 1
else poscnt[1];

def negcnt = if bn == 1 then 0
 else if diff <= negative_percent then negcnt[1] + 1
else negcnt[1];

addlabel(1, poscnt + " changes >= " + positive_percent + "%", color.green);

addlabel(1, negcnt + " changes <= " + negative_percent + "%", color.red);
 
Solution
is this what you are looking for?
add this to the end of the histo code

Code:
def bn = barnumber();
input positive_percent = 1.0:
input negative_percent = -1.0:

def poscnt = if bn == 1 then 0
 else if diff >= positive_percent then poscnt[1] + 1
else poscnt[1];

def negcnt = if bn == 1 then 0
 else if diff <= negative_percent then negcnt[1] + 1
else negcnt[1];

addlabel(1, poscnt + " changes >= " + positive_percent + "%", color.green);

addlabel(1, negcnt + " changes <= " + negative_percent + "%", color.red);
@halcyonguy is there anyway there is a code of this for dollar up positive and negative counter? I love the percentage counter, but I was wondering if you are aware of the asdollar count bar, similar as these percentage count bar but than asdollar points up or down. I was trying to use this code to change it to Upcount/downcount but that is not working. Thank you for your help!
 
is this what you are looking for?
add this to the end of the histo code

Code:
def bn = barnumber();
input positive_percent = 1.0:
input negative_percent = -1.0:

def poscnt = if bn == 1 then 0
 else if diff >= positive_percent then poscnt[1] + 1
else poscnt[1];

def negcnt = if bn == 1 then 0
 else if diff <= negative_percent then negcnt[1] + 1
else negcnt[1];

addlabel(1, poscnt + " changes >= " + positive_percent + "%", color.green);

addlabel(1, negcnt + " changes <= " + negative_percent + "%", color.red);
Yes, this works! Thank you very much! (y)
 

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