• Get $40 off VIP by signing up for a free account! Sign Up

Add Labels to ToS Price Channel Indicator

robopro

New member
VIP
The indicator is PriceChannel
this picture pretty much explains it...

https://gyazo.com/ad776e4ee8df16dd4eae3fc45a64dd15

What i need is a label and arrow when the candle touches the pricechannel.
Label should read DOWN when the pricechannel line is coming down and
the candle touches the pricechannel line hitting the top as you see in the above picture.


And also the reverse as you see in the picture below.

https://gyazo.com/fededd8213d0737aaca8b0972ea0f4fb

Thank you


this is the indicator source.

#
# TD Ameritrade IP Company, Inc. (c) 2007-2022
#

input displace = 0;
input length = 20;

plot LowerBand = Lowest(low[-displace + 1], length);
LowerBand.SetDefaultColor(GetColor(8));

plot UpperBand = Highest(high[-displace + 1], length);
UpperBand.SetDefaultColor(GetColor(1));
 
Last edited:
The indicator is PriceChannel
this picture pretty much explains it...

https://gyazo.com/ad776e4ee8df16dd4eae3fc45a64dd15

What i need is a label and arrow when the candle touches the pricechannel.
Label should read DOWN when the pricechannel line is coming down and
the candle touches the pricechannel line hitting the top as you see in the above picture.


And also the reverse as you see in the picture below.

https://gyazo.com/fededd8213d0737aaca8b0972ea0f4fb

Thank you


this is the indicator source.

#
# TD Ameritrade IP Company, Inc. (c) 2007-2022
#

input displace = 0;
input length = 20;

plot LowerBand = Lowest(low[-displace + 1], length);
LowerBand.SetDefaultColor(GetColor(8));

plot UpperBand = Highest(high[-displace + 1], length);
UpperBand.SetDefaultColor(GetColor(1));

To be able to assist you, please define what constitutes a touch. In you picture, it is unclear. For example, does touch mean close = one of the bands, or a close = one the bands and the wick extends through the band, etc...etc...?
 
I won't speak for the OP, but in general, when looking at Donchain or Price Channel, touch is considered when a wick goes through to set a new band or equals the existing one.
 
I won't speak for the OP, but in general, when looking at Donchain or Price Channel, touch is considered when a wick goes through to set a new band or equals the existing one.

This is meant to do what you suggested as touches and robopro's bubbles and color coding. The bubbles appear when a new touch different the previous touch occurs. In other words, if there are consecutive bars that have touches of the same type, only the first of those will plot a bubble.

Screenshot-2022-10-20-114250.png
Ruby:
#
# TD Ameritrade IP Company, Inc. (c) 2007-2022
#

input displace = 0;
input length = 20;

plot LowerBand = Lowest(low[-displace + 1], length);
LowerBand.SetDefaultColor(GetColor(8));

plot UpperBand = Highest(high[-displace + 1], length);
UpperBand.SetDefaultColor(GetColor(1));

def touch = if (Max(close, open) < UpperBand and high >= UpperBand) or high==upperband
            then 1
            else if (Min(close, open) > LowerBand and low < LowerBand) or low==lowerband
            then -1
            else 0;

def lowerdir   = if LowerBand <= LowerBand[1]
                 then -1
                 else if LowerBand >= LowerBand[1]
                 then 1
                 else lowerdir[1];

AddChartBubble(touch[1] == 0 and touch == -1,
               low,
               if lowerdir == -1 then "DN" else "UP",
               if lowerdir == -1 then Color.RED else Color.GREEN,
               no);

def upperdir  = if UpperBand >= UpperBand[1]
                 then 1
                 else if UpperBand <= UpperBand[1]
                 then -1
                 else upperdir[1];

AddChartBubble(touch[1] == 0 and touch == 1,
               high, 
               if upperdir == -1 then "DOWN" else "UP",
               if upperdir == -1 then Color.RED else Color.GREEN,
               yes);
#
 
To be able to assist you, please define what constitutes a touch. In you picture, it is unclear. For example, does touch mean close = one of the bands, or a close = one the bands and the wick extends through the band, etc...etc...?
Hi SleepyZ, Thank you for helping....as soon as it hits the band in any which way.
Here is another example
What's important is that an up or down trend is determined first. There needs to be a significant slope before it can be considered.
https://gyazo.com/b6e1b35213296efff235b8acef36348c
or from your pic
https://gyazo.com/dd34b494cd3e8e383f103d4fa7b50d82

Basically its a retracement of the trend, Ex; trend is down, price action retraces back up to the band and then back down she goes
 
Last edited:
Hi SleepyZ, Thank you for helping....as soon as it hits the band in any which way.
Here is another example
What's important is that an up or down trend is determined first. There needs to be a significant slope before it can be considered.
https://gyazo.com/b6e1b35213296efff235b8acef36348c
or from your pic
https://gyazo.com/dd34b494cd3e8e383f103d4fa7b50d82

Basically its a retracement of the trend, Ex; trend is down, price action retraces back up to the band and then back down she goes

This might get you started for what you want.

It sets a direction for each band. If the directions match and then there is a retracement hits the opposite band, an "X" bubble will appear.

There is no determination of strength of move, just that they match and then a retracement hits the opposite band.

You can set test to YES to see the 1/0 used.

Screenshot-2022-10-21-074340.png
Ruby:
#
# TD Ameritrade IP Company, Inc. (c) 2007-2022
#

input displace = 0;
input length = 20;

plot LowerBand = Lowest(low[-displace + 1], length);
LowerBand.SetDefaultColor(GetColor(8));

plot UpperBand = Highest(high[-displace + 1], length);
UpperBand.SetDefaultColor(GetColor(1));


def upperdir  = if high crosses above UpperBand
                 then 1
                 else if upperdir[1] >= 1 and UpperBand >= UpperBand[1]
                 then 1
                 else if UpperBand < UpperBand[1] then 0
                 else upperdir[1];

def lowerdir   = if high crosses above upperBand
                 then 1
                 else if lowerdir[1] >= 1 and LowerBand >= LowerBand[1]
                 then 1
                 else if LowerBand < LowerBand[1] then 0
                 else lowerdir[1];


def change_dir = if upperdir[1] + lowerdir[1] == 2 and upperdir + lowerdir == 1 or upperdir[1]+lowerdir[1] == 0 and upperdir+lowerdir == 2 then 1 else Double.NaN;

AddChartBubble(!IsNaN(change_dir), if !isnan(change_dir) and upperdir[1] == 0 and upperdir==1 then upperBand else lowerBand, " X ", Color.YELLOW, if upperdir[1] == 1 and upperdir == 1 then no else yes);

#test
input test = no;
plot xdndir = lowerdir;
xdndir.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
xdndir.SetHiding(!test);

plot xupdir = if UpperBand then upperdir else Double.NaN;
xupdir.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
xupdir.SetHiding(!test);

#
 

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