hi need help changing color of indicator

Caddytrader

New member
Hey guys , Im new here ( please go easy on me ) Im trying to figure out if its possible to change this percent b indicator color when the percent crosses 100 BUT does NOT close above 100. same for when the percent crosses 0 but does NOT close below 0...

let me know you guys think, thanks





#
# TD Ameritrade IP Company, Inc. (c) 2008-2023
#

declare lower;

input averageType = AverageType.Simple;
input price = close;
input displace = 0;
input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;

def upperBand = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_up, averageType).UpperBand;
def lowerBand = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_up, averageType).LowerBand;

plot PercentB = (price - lowerBand) / (upperBand - lowerBand) * 100;
plot ZeroLine = 0;
plot HalfLine = 50;
plot UnitLine = 100;

PercentB.SetDefaultColor(GetColor(1));
PercentB.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
PercentB.SetLineWeight(3);
ZeroLine.SetDefaultColor(GetColor(8));
HalfLine.SetDefaultColor(GetColor(8));
UnitLine.SetDefaultColor(GetColor(8));
 
Solution
Hi and welcome to UTS!

If you mean by "crosses zero but does not close below zero" that while the bar is the current bar the value has dipped momentarily below the threshold and come back up, that kind of data is not available to us in ThinkScript. ToS only allows us to access the 5 main values (open, high, low, close, and volume) for any given instrument. It does not store and make available values inside a bar (so a 1 hour bar has only the open etc... and does not have minute by minute data).

If the data you want to change the color of has a distinct high and low in addition to the close, then you could change the color based on the low crossing below zero or the high crossing above 100, but it looks like the indicator you...
Hi and welcome to UTS!

If you mean by "crosses zero but does not close below zero" that while the bar is the current bar the value has dipped momentarily below the threshold and come back up, that kind of data is not available to us in ThinkScript. ToS only allows us to access the 5 main values (open, high, low, close, and volume) for any given instrument. It does not store and make available values inside a bar (so a 1 hour bar has only the open etc... and does not have minute by minute data).

If the data you want to change the color of has a distinct high and low in addition to the close, then you could change the color based on the low crossing below zero or the high crossing above 100, but it looks like the indicator you have chosen has only one line (which even if the bar goes above 100 / below zero inside a bar only has the close value available) and so can't be handled that way.

We are also not allowed to use lower aggregations (1 min) on higher time frame charts (like 10 min) to get inter-bar information. The best you could do in that regard is to have two separate charts going.

Hope that helps, if you need further explanation or have another idea, feel free to bring it back here
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
286 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