Thanks @SleepyZ!Yes, it works for me.
Thanks @SleepyZ!Yes, it works for me.
I'd love to circle back to this indicator to see if anyone has seen it as a label. Showing where price in relationship to each channel so I don't have to have these 6 lines on my chartYes, it works for me.
View attachment 2302
# Upper Chart Labels Only
# Indicator that presents ATR 1,2,3 above and below using Keltner channel formula
input displace = 0;
input factor1 = 1.0;
input factor2 = 2.0;
input factor3 = 3.0;
input length = 21;
input price = close;
input averageType = AverageType.SIMPLE;
input trueRangeAverageType = AverageType.SIMPLE;
def shift1 = factor1 * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def shift2 = factor2 * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def shift3 = factor3 * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def average = MovingAverage(averageType, price, length);
def Upper_Band1 = average[-displace] + shift1[-displace];
def Upper_Band2 = average[-displace] + shift2[-displace];
def Upper_Band3 = average[-displace] + shift3[-displace];
def Lower_Band1 = average[-displace] - shift1[-displace];
def Lower_Band2 = average[-displace] - shift2[-displace];
def Lower_Band3 = average[-displace] - shift3[-displace];
AddLabel(yes,"close==" +asdollars(close) +" keltner average==" +asdollars(average),
if close>average then color.green else color.red);
AddLabel(yes," lower3==" +asdollars(Lower_Band3),
if close>Lower_Band3 then color.green else color.red);
AddLabel(yes," lower2==" +asdollars(Lower_Band2),
if close>Lower_Band2 then color.green else color.red);
AddLabel(yes," lower1==" +asdollars(Lower_Band1),
if close>Lower_Band1 then color.green else color.red);
AddLabel(yes," upper1==" +asdollars(Upper_Band1),
if close>Upper_Band1 then color.green else color.red);
AddLabel(yes," upper2==" +asdollars(Upper_Band2),
if close>Upper_Band2 then color.green else color.red);
AddLabel(yes," upper3==" +asdollars(Upper_Band3),
if close>Upper_Band3 then color.green else color.red);
This is great. I'm just wondering if we could make it 1 label instead of 3 labels. The one label would change pending on where price is relative to the channels?Member request
These are the price levels of the Keltner ATR bands.
This study removes the messy lines and just provides a label.
Label coloring: if close is above the channel green else red.
@bsturgRuby:# Upper Chart Labels Only # Indicator that presents ATR 1,2,3 above and below using Keltner channel formula input displace = 0; input factor1 = 1.0; input factor2 = 2.0; input factor3 = 3.0; input length = 21; input price = close; input averageType = AverageType.SIMPLE; input trueRangeAverageType = AverageType.SIMPLE; def shift1 = factor1 * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length); def shift2 = factor2 * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length); def shift3 = factor3 * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length); def average = MovingAverage(averageType, price, length); def Upper_Band1 = average[-displace] + shift1[-displace]; def Upper_Band2 = average[-displace] + shift2[-displace]; def Upper_Band3 = average[-displace] + shift3[-displace]; def Lower_Band1 = average[-displace] - shift1[-displace]; def Lower_Band2 = average[-displace] - shift2[-displace]; def Lower_Band3 = average[-displace] - shift3[-displace]; AddLabel(yes,"close==" +asdollars(close) +" keltner average==" +asdollars(average), if close>average then color.green else color.red); AddLabel(yes," lower3==" +asdollars(Lower_Band3), if close>Lower_Band3 then color.green else color.red); AddLabel(yes," lower2==" +asdollars(Lower_Band2), if close>Lower_Band2 then color.green else color.red); AddLabel(yes," lower1==" +asdollars(Lower_Band1), if close>Lower_Band1 then color.green else color.red); AddLabel(yes," upper1==" +asdollars(Upper_Band1), if close>Upper_Band1 then color.green else color.red); AddLabel(yes," upper2==" +asdollars(Upper_Band2), if close>Upper_Band2 then color.green else color.red); AddLabel(yes," upper3==" +asdollars(Upper_Band3), if close>Upper_Band3 then color.green else color.red);
This is great. I'm just wondering if we could make it 1 label instead of 3 labels. The one label would change pending on where price is relative to the channels?
Code:# Upper Chart Labels Only # Indicator that presents ATR 1,2,3 above and below using Keltner channel formula input displace = 0; input factor1 = 1.0; input factor2 = 2.0; input factor3 = 3.0; input length = 21; input price = close; input averageType = AverageType.SIMPLE; input trueRangeAverageType = AverageType.SIMPLE; def shift1 = factor1 * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length); def shift2 = factor2 * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length); def shift3 = factor3 * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length); def average = MovingAverage(averageType, price, length); def Upper_Band1 = average[-displace] + shift1[-displace]; def Upper_Band2 = average[-displace] + shift2[-displace]; def Upper_Band3 = average[-displace] + shift3[-displace]; def Lower_Band1 = average[-displace] - shift1[-displace]; def Lower_Band2 = average[-displace] - shift2[-displace]; def Lower_Band3 = average[-displace] - shift3[-displace]; AddLabel(Between(close, Lower_Band1, Upper_Band1), "close==" + AsDollars(close) + (if close < average then " < " else " > ") + " keltner average==" + AsDollars(average), if close > average then Color.LIGHT_GREEN else Color.LIGHT_RED); AddLabel(close < Lower_Band3, "close==" + AsDollars(close) + " < lower3==" + AsDollars(Lower_Band3), Color.LIGHT_RED); AddLabel(Between(close, Lower_Band3, Lower_Band2), "close==" + AsDollars(close) + " < lower2==" + AsDollars(Lower_Band2), Color.LIGHT_RED); AddLabel(Between(close, Lower_Band2, Lower_Band1), "close==" + AsDollars(close) + " < lower1==" + AsDollars(Lower_Band1), Color.LIGHT_RED); AddLabel(Between(close, Upper_Band1, Upper_Band2), "close==" + AsDollars(close) + " > upper1==" + AsDollars(Upper_Band1), Color.LIGHT_GREEN); AddLabel(Between(close, Upper_Band2, Upper_Band3), "close==" + AsDollars(close) + " > upper2==" + AsDollars(Upper_Band2), Color.LIGHT_GREEN); AddLabel(close > Upper_Band3, "close==" + AsDollars(close) + " > upper3==" + AsDollars(Upper_Band3), Color.LIGHT_GREEN); #
Here is one way to have 1 label: If close is above/below a level then either a green/red label will appear with the close price, a " > or < ", and the level (average or upper/lower bands 1/2/3)
The image shows the lines for comparison purposes only.
Code:# Upper Chart Labels Only # Indicator that presents ATR 1,2,3 above and below using Keltner channel formula input label_option = {default More, Less, Bubble}; input displace = 0; input factor1 = 1.0; input factor2 = 2.0; input factor3 = 3.0; input length = 21; input price = close; input averageType = AverageType.SIMPLE; input trueRangeAverageType = AverageType.SIMPLE; def shift1 = factor1 * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length); def shift2 = factor2 * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length); def shift3 = factor3 * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length); def average = MovingAverage(averageType, price, length); def Upper_Band1 = average[-displace] + shift1[-displace]; def Upper_Band2 = average[-displace] + shift2[-displace]; def Upper_Band3 = average[-displace] + shift3[-displace]; def Lower_Band1 = average[-displace] - shift1[-displace]; def Lower_Band2 = average[-displace] - shift2[-displace]; def Lower_Band3 = average[-displace] - shift3[-displace]; AddLabel(if label_option==label_option.bubble then double.nan else Between(close, Lower_Band1, Upper_Band1), if label_option==label_option.less then "AVG" else "close==" + AsDollars(close) + (if close < average then " < " else " > ") + " keltner average==" + AsDollars(average), if close > average then Color.LIGHT_GREEN else Color.LIGHT_RED); AddLabel(if label_option==label_option.bubble then double.nan else close < Lower_Band3, if label_option==label_option.less then "L-3" else "close==" + AsDollars(close) + " < lower3==" + AsDollars(Lower_Band3), Color.LIGHT_RED); AddLabel(if label_option==label_option.bubble then double.nan else Between(close, Lower_Band3, Lower_Band2), if label_option==label_option.less then "L-2" else "close==" + AsDollars(close) + " < lower2==" + AsDollars(Lower_Band2), Color.LIGHT_RED); AddLabel(if label_option==label_option.bubble then double.nan else Between(close, Lower_Band2, Lower_Band1), if label_option==label_option.less then "L-1" else "close==" + AsDollars(close) + " < lower1==" + AsDollars(Lower_Band1), Color.LIGHT_RED); AddLabel(if label_option==label_option.bubble then double.nan else Between(close, Upper_Band1, Upper_Band2), if label_option==label_option.less then "U-1" else "close==" + AsDollars(close) + " > upper1==" + AsDollars(Upper_Band1), Color.LIGHT_GREEN); AddLabel(if label_option==label_option.bubble then double.nan else Between(close, Upper_Band2, Upper_Band3), if label_option==label_option.less then "U-2" else "close==" + AsDollars(close) + " > upper2==" + AsDollars(Upper_Band2), Color.LIGHT_GREEN); AddLabel(if label_option==label_option.bubble then double.nan else close > Upper_Band3, if label_option==label_option.less then "U-3" else "close==" + AsDollars(close) + " > upper3==" + AsDollars(Upper_Band3), Color.LIGHT_GREEN); #---------------------------- #Bubble option input bubblemover = 2; def b = bubblemover; def b1 = b + 1; addchartbubble(close[b1]>= Average[b1] and label_option==label_option.bubble and isnan(close[b]) and !isnan(close[b1]), close[b1], if Between(close[b1], Lower_Band1[b1], Upper_Band1[b1]) then "AVG" else if close[b1]>Upper_Band3[b1] then "U-3" else if Between(close[b1], Upper_Band2[b1], Upper_Band3[b1]) then "U-2" else "U-1", color.green); addchartbubble(close[b1]< Average[b1] and label_option==label_option.bubble and isnan(close[b]) and !isnan(close[b1]), close[b1], if Between(close[b1], Lower_Band1[b1], Upper_Band1[b1]) then "AVG" else if close[b1]<Lower_Band3[b1] then "L-3" else if Between(close[b1], Lower_Band3[b1], Lower_Band2[b1]) then "L-2" else "L-1", color.light_red); #
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
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.
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.