3 ATR Bands using Keltner Channels for ThinkorSwim

irishgold

Active member
Have not seen this code on the site, I watched John Carter using these bands to restrict his trades. The code is based on the TOS Keltner Channel code. I think it has good value in trading levels. It's basically 6 keltner channels with std deviation of 1,2,3,-1,-2,-3

Rich (BB code):
# 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);

plot average = MovingAverage(averageType, price, length);
average.SetDefaultColor(GetColor(4));

plot Upper_Band1 = average[-displace] + shift1[-displace];
Upper_Band1 .SetDefaultColor(GetColor(6));
plot Upper_Band2  = average[-displace] + shift2[-displace];
Upper_Band2 .SetDefaultColor(GetColor(0));
plot Upper_Band3 = average[-displace] + shift3[-displace];
Upper_Band3.SetDefaultColor(GetColor(5));

plot Lower_Band1 = average[-displace] - shift1[-displace];
Lower_Band1 .SetDefaultColor(GetColor(6));
plot Lower_Band2  = average[-displace] - shift2[-displace];
Lower_Band2 .SetDefaultColor(GetColor(0));
plot Lower_Band3 = average[-displace] - shift3[-displace];
Lower_Band3.SetDefaultColor(GetColor(5));
 

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

any idea how to take advantage of these lines ....? As much i understood ... it should bounce from the line , but thats not the case ... lots of time it does keep going and bounce
 
It's just another tool to measure when price is reaching a range that the instrument is trading in. As you reach the upper 3 ATR level it's probably not a good time to get in and if already in to get out. On Thinkorswim you have expected moves so it is something of that nature.
Here's a good explanation of the Keltner channels: https://bullishbears.com/keltner-channels/
 
Have not seen this code on the site, I watched John Carter using these bands to restrict his trades. The code is based on the TOS Keltner Channel code. I think it has good value in trading levels. It's basically 6 keltner channels with std deviation of 1,2,3,-1,-2,-3

Rich (BB code):
# 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);

plot average = MovingAverage(averageType, price, length);
average.SetDefaultColor(GetColor(4));

plot Upper_Band1 = average[-displace] + shift1[-displace];
Upper_Band1 .SetDefaultColor(GetColor(6));
plot Upper_Band2  = average[-displace] + shift2[-displace];
Upper_Band2 .SetDefaultColor(GetColor(0));
plot Upper_Band3 = average[-displace] + shift3[-displace];
Upper_Band3.SetDefaultColor(GetColor(5));

plot Lower_Band1 = average[-displace] - shift1[-displace];
Lower_Band1 .SetDefaultColor(GetColor(6));
plot Lower_Band2  = average[-displace] - shift2[-displace];
Lower_Band2 .SetDefaultColor(GetColor(0));
plot Lower_Band3 = average[-displace] - shift3[-displace];
Lower_Band3.SetDefaultColor(GetColor(5));
add this to get colored bands

AddCloud(Upper_Band1, Lower_Band1, Color.LIME, CreateColor(175, 250, 175), no);
AddCloud(Upper_Band3, Upper_Band2, Color.PINK, CreateColor(175, 250, 175), no);
AddCloud(Lower_Band2, Lower_Band3, Color.PINK, CreateColor(175, 250, 175), no);
 
I believe they are 1.0, 1.5, and 2.0 ATR... Those are the TTM_Squeeze_Pro settings and what I used when I wrote my code before ever seeing John Carters...
I am in his class, that's all we talk about daily. 3ATR is the buy or sell point where 1ATR is the mean reversion target. I am looking for some help if the Keltner Channel can be scripted for the last 20 bars only, as not to clutter the chart. Sort of like an Anchored ATR channel that floating with 2ATR and 3ATR levels. @rad14733
 
Ahhh... Different indicator altogether, without Bollinger Bands...

I haven't played much with partial displays but @XeoNoX and @SleepyZ have posted code on how to go about it as I recall...

Here is an old version of Keltner Channel that I did that is modified to just display the KC for display_xbars input
Code:
#KeltnerChannel_Limited_Display
#20210606 Sleepyz Usethinkscript request
#KC limited plot to last display_xbars input

input display_xbars = 20;
input factor1  = 1.0;
input factor2  = 2.0;
input factor3  = 3.0;
input length   =  20;
input price    = close;
input trlength = 20;

input Avgtype_ma  = AverageType.SIMPLE;
input Avgtype_tr  = AverageType.EXPONENTIAL;
def tr = MovingAverage(Avgtype_tr, TrueRange(high, close, low), trlength);

#Display limited to last xbars
def lastbar  = if IsNaN(close[-1]) and !IsNaN(close) then BarNumber() else Double.NaN;
plot Average = if BarNumber() < HighestAll(lastbar - display_xbars)
               then Double.NaN
               else MovingAverage(Avgtype_ma, price, length);
###########

plot Upper_Band  = Average + tr * factor1;
plot Lower_Band  = Average - tr * factor1;
plot Upper_Band2 = Average + tr * factor2;
plot Lower_Band2 = Average - tr * factor2;
plot Upper_Band3 = Average + tr * factor3;
plot Lower_Band3 = Average - tr * factor3;

def dir = if (Average) > (Average[1]) and Upper_Band > Upper_Band[1] and Lower_Band > Lower_Band[1] then 1 else if (Average) < (Average[1]) and Upper_Band < Upper_Band[1] and Lower_Band < Lower_Band[1] then 2 else 0;
Average.AssignValueColor(if dir == 1 then Color.GREEN  else if dir == 2 then Color.RED else Color.WHITE);
Upper_Band.AssignValueColor(if dir == 1 then Color.GREEN  else if dir == 2 then Color.RED else Color.WHITE);
Lower_Band.AssignValueColor(if dir == 1 then Color.GREEN  else if dir == 2 then Color.RED else Color.WHITE);
Upper_Band2.AssignValueColor(if dir == 1 then Color.GREEN  else if dir == 2 then Color.RED else Color.WHITE);
Lower_Band2.AssignValueColor(if dir == 1 then Color.GREEN  else if dir == 2 then Color.RED else Color.WHITE);
Upper_Band3.SetDefaultColor(Color.BLACK);
Lower_Band3.SetDefaultColor(Color.BLACK);
Upper_Band3.SetStyle(Curve.SHORT_DASH);
Lower_Band3.SetStyle(Curve.SHORT_DASH);

Average.HideBubble();
Upper_Band.HideBubble();
Lower_Band.HideBubble();
Upper_Band2.HideBubble();
Lower_Band2.HideBubble();
Upper_Band3.HideBubble();
Lower_Band3.HideBubble();

input showclouds = yes;
AddCloud(if showclouds and Round(low) <= Round(Lower_Band2) then Lower_Band2 else Double.NaN, Lower_Band3, Color.MAGENTA, color2 = Color.MAGENTA);
AddCloud(if showclouds and Round(high) >= Round(Upper_Band2) then Upper_Band2 else Double.NaN, Upper_Band3, Color.MAGENTA, color2 = Color.MAGENTA);

input usealerts = no;
Alert(usealerts and close crosses below Upper_Band2, "Close below UB", Alert.BAR, Sound.Ring);
Alert(usealerts and close crosses above Lower_Band2, "Close above LB", Alert.BAR, Sound.Ring);


input showclouds_ul = yes;
AddCloud(if showclouds_ul and dir == 1 then Upper_Band2 else Upper_Band, if dir == 1 then Upper_Band else Upper_Band2, Color.GREEN, Color.RED);

AddCloud(if showclouds_ul and dir == 2 then Lower_Band else Lower_Band2, if dir == 2 then Lower_Band2 else Lower_Band, Color.RED, Color.GREEN);

input showlabel = yes;
AddLabel(showlabel, if dir == 1 then "KC-All Up" else if dir == 2 then "KC-All Down" else "KC-Mixed", if dir == 1 then Color.GREEN else if dir == 2 then Color.RED else Color.WHITE);

AddLabel(showlabel, "KC-AVG", if Average > Average[1] then Color.GREEN else if Average < Average[1] then Color.RED else Color.WHITE);

AddLabel(showlabel, "KC-UB", if Upper_Band > Upper_Band[1] then Color.GREEN else if Upper_Band < Upper_Band[1] then Color.RED else Color.WHITE);

AddLabel(showlabel, "KC-LB", if Lower_Band > Lower_Band[1] then Color.GREEN else if Lower_Band < Lower_Band[1] then Color.RED else Color.WHITE);

def span = Upper_Band - Lower_Band;
AddLabel(showlabel, "U-L " + AsText(span), if Round(span) > Round(span[1]) then Color.GREEN else Color.RED);

input bubblemover = 5;
def bm = bubblemover + 1;
input bubblemoverupdown = 0;
input showbubble_avg_ub_lb = yes;
AddChartBubble(showbubble_avg_ub_lb and IsNaN(close[bubblemover]) and !IsNaN(close[bm]), Upper_Band[bm] + bubblemoverupdown * TickSize(), "UB " + AsText(Upper_Band[bm]), if Upper_Band[bm] > Upper_Band[bm + 1] then Color.GREEN else if Upper_Band[bm] < Upper_Band[bm + 1] then Color.RED else Color.WHITE);
AddChartBubble(showbubble_avg_ub_lb and IsNaN(close[bubblemover]) and !IsNaN(close[bm]), Lower_Band[bm] + bubblemoverupdown * TickSize(), "LB " + AsText(Lower_Band[bm]), if Lower_Band[bm] > Lower_Band[bm + 1] then Color.GREEN else if Lower_Band[bm] < Lower_Band[bm + 1] then Color.RED else Color.WHITE);

AddChartBubble(showbubble_avg_ub_lb and IsNaN(close[bubblemover]) and !IsNaN(close[bm]), Average[bm] + bubblemoverupdown * TickSize(), "AVG " +  AsText(Average[bm]), if Average[bm] > Average[bm + 1] then Color.GREEN else if Average[bm] < Average[bm + 1] then Color.RED else Color.WHITE);

input bubblemover_ul = 2;
def bm_ul = bubblemover_ul + 1;
input bubblemoverupdown_ul = 0;
input showbubble_ul = yes;
AddChartBubble(showbubble_ul and IsNaN(close[bubblemover_ul]) and !IsNaN(close[bm_ul]), close[bm_ul] + bubblemoverupdown_ul * TickSize(), "U-L\n" + AsText(Round(span[bm_ul])), if Round(span[bm_ul]) > Round(span[bm_ul + 1]) then Color.GREEN else if Round(span[bm_ul]) < Round(span[bm_ul + 1]) then Color.RED else Color.WHITE);
Capture.jpg
 
Here is an old version of Keltner Channel that I did that is modified to just display the KC for display_xbars input
@SleepyZ you are a genius! Thank you so very much! Could we just have the lines and without the cloud? and without the price bubbles. Just like your Anchored VWAP, simpler version of it.
 
Last edited:
@SleepyZ you are a genius! Thank you so very much! Could we just have the lines and without the cloud? and without the price bubbles. Just like your Anchored VWAP, simpler version of it.

Here is simpler version
Code:
input display_xbars = 20;
input factor1  = 1.0;
input factor2  = 2.0;
input factor3  = 3.0;
input length   =  20;
input price    = close;
input trlength = 20;

input Avgtype_ma  = AverageType.SIMPLE;
input Avgtype_tr  = AverageType.EXPONENTIAL;
def tr = MovingAverage(Avgtype_tr, TrueRange(high, close, low), trlength);

#Display limited to last xbars
def lastbar  = if IsNaN(close[-1]) and !IsNaN(close) then BarNumber() else Double.NaN;
plot Average = if BarNumber() < HighestAll(lastbar - display_xbars)
               then Double.NaN
               else MovingAverage(Avgtype_ma, price, length);
###########

plot Upper_Band  = Average + tr * factor1;
plot Lower_Band  = Average - tr * factor1;
plot Upper_Band2 = Average + tr * factor2;
plot Lower_Band2 = Average - tr * factor2;
plot Upper_Band3 = Average + tr * factor3;
plot Lower_Band3 = Average - tr * factor3;

Average.setdefaultColor(color.yellow);
Upper_Band.setdefaultColor(color.green);
Lower_Band.setdefaultColor(color.red);
Upper_Band2.setdefaultColor(color.green);
Lower_Band2.setdefaultColor(color.red);
Upper_Band3.setdefaultColor(color.green);
Lower_Band3.setdefaultColor(color.red);

Average.HideBubble();
Upper_Band.HideBubble();
Lower_Band.HideBubble();
Upper_Band2.HideBubble();
Lower_Band2.HideBubble();
Upper_Band3.HideBubble();
Lower_Band3.HideBubble();
 
Member request
Bnb5Nfk.png

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.
N6G5sqX.png

Ruby:
# 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);
@bsturg
 
Last edited:
Member request
Bnb5Nfk.png

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.
N6G5sqX.png

Ruby:
# 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);
@bsturg
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?
 
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?

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.
Screenshot 2024-09-03 142849.jpg
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.

This has more options, but is still one label or bubble.
The input label_option has more, less or bubble as the options.
The more is the label (eg:
Screenshot 2024-09-04 130632.jpg
, less is
Screenshot 2024-09-04 131003.jpg
and the bubble is the less label view floating with the close in the right expansion.
The bubble can be moved sideways at the input bubblemover;

The image shows the bubble with the lines added for comparion

Screenshot 2024-09-04 125953.jpg
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);
#
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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