# Momentum Bollinger Band Channels for ThinkorSwim

#### XeoNoX

##### Expert
VIP
Momentum Bollinger Band channels indicator for TOS Thinkscript Thinkorswim

(Based of Pensar's Keltner channel Momentum which is based on which is based on FW-MOBO-Advanced https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/E-F/FW-MOBO-Advanced) as per @acjtumio1987 request

Remember to Thumbs up if you found this post useful

Code:
#Momentum Bollinger band channel v1.0 by XeoNoX via usethinkscript.com
#Request 03-16-2021
#Based of Pensar's Keltner channel Momentum bands via usethinkscript.com
#Inputs
input factor       =     0.5;
input price        =     close;
input type         =     AverageType.SIMPLE;
input pricecolor   =     yes;
input fill         =     yes;
input arrows       =     yes;
input sound        =     {default "Ding", "Bell", "Chimes", "NoSound", "Ring"};
input displace = 0;
input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.SIMPLE;

def sDev = StDev(data = price[-displace], length = length);

#Variables
def nan      =   Double.NaN;
def shift    =   factor * MovingAverage(type, TrueRange(high, close, low), length);
plot avg     = MovingAverage(averageType, data = price[-displace], length = length);
def line1    =   avg + Num_Dev_Dn * sDev;
def line2    =    avg + Num_Dev_up * sDev;
def Chg      =   If(close > line2, 1, If(close < line1, -1, 0));
def Hold     =   CompoundValue(1, If(Hold[1] == Chg or Chg == 0, Hold[1], If(Chg == 1, 1, -1)), 0);
def ArUp     =   if !arrows or Hold[0] == Hold[1] then nan else if Hold[0] == 1 then line1 else nan;
def ArDn     =   if !arrows or Hold[0] == Hold[1] then nan else if Hold[0] == -1 then line2 else nan;
def LBUp     =   if fill and Hold[0] == 1 then line2 else nan;
def UBUp     =   if fill and Hold[0] == 1 then line1 else nan;
def LBDn     =   if fill and Hold[0] == -1 then line2 else nan;
def UBDn     =   if fill and Hold[0] == -1 then line1 else nan;
def AlertUp  =   alerts and Hold[1] ==  1 and (Hold[1] <> Hold[2]);
def AlertDn  =   alerts and Hold[1] == -1 and (Hold[1] <> Hold[2]);

#Colors
DefineGlobalColor("Cloud Up", Color.DARK_GREEN);
DefineGlobalColor("Cloud Dn", Color.DARK_RED);
DefineGlobalColor("Channel Up", Color.GREEN);
DefineGlobalColor("Channel Down", Color.RED);
DefineGlobalColor("Price Up", Color.GREEN);
DefineGlobalColor("Price Neutral", Color.GRAY);
DefineGlobalColor("Price Down", Color.RED);

#Plots
plot UB = line1;
UB.SetLineWeight(1);
UB.AssignValueColor(if Hold[0] == 1 then GlobalColor("Channel Up")
else GlobalColor("Channel Down"));
plot LB = line2;
LB.SetLineWeight(1);
LB.AssignValueColor(if Hold[0] == 1 then GlobalColor("Channel Up")
else GlobalColor("Channel Down"));
plot BOA = ArUp;
BOA.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BOA.SetDefaultColor(Color.GREEN);
BOA.SetLineWeight(2);
plot BDA = ArDn;
BDA.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
BDA.SetDefaultColor(Color.RED);
BDA.SetLineWeight(2);

#Clouds
AddCloud(LBUp, UBUp, GlobalColor("Cloud Up"), GlobalColor("Cloud Dn"));
AddCloud(LBDn, UBDn, GlobalColor("Cloud Dn"), GlobalColor("Cloud Up"));

#Price Color
AssignPriceColor(if pricecolor then if close > line2 then GlobalColor("Price Up")
else if close < line1 then GlobalColor("Price Down")
else GlobalColor("Price Neutral")
else Color.CURRENT);

# --- End code ---

Last edited:
Thank you so much, and happy trading!

damn im pretty bored today.

Very nice - I thumbs up'd it - well done - thank you

Momentum Bollinger Band channels indicator for TOS Thinkscript Thinkorswim

(Based of Pensar's Keltner channel Momentum which is based on which is based on FW-MOBO-Advanced https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/E-F/FW-MOBO-Advanced) as per @acjtumio1987 request

Remember to Thumbs up if you found this post useful

Code:
#Momentum Bollinger band channel v1.0 by XeoNoX via usethinkscript.com
#Request 03-16-2021
#Based of Pensar's Keltner channel Momentum bands via usethinkscript.com
#Inputs
input factor       =     0.5;
input price        =     close;
input type         =     AverageType.SIMPLE;
input pricecolor   =     yes;
input fill         =     yes;
input arrows       =     yes;
input sound        =     {default "Ding", "Bell", "Chimes", "NoSound", "Ring"};
input displace = 0;
input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.SIMPLE;

def sDev = StDev(data = price[-displace], length = length);

#Variables
def nan      =   Double.NaN;
def shift    =   factor * MovingAverage(type, TrueRange(high, close, low), length);
plot avg     = MovingAverage(averageType, data = price[-displace], length = length);
def line1    =   avg + Num_Dev_Dn * sDev;
def line2    =    avg + Num_Dev_up * sDev;
def Chg      =   If(close > line2, 1, If(close < line1, -1, 0));
def Hold     =   CompoundValue(1, If(Hold[1] == Chg or Chg == 0, Hold[1], If(Chg == 1, 1, -1)), 0);
def ArUp     =   if !arrows or Hold[0] == Hold[1] then nan else if Hold[0] == 1 then line1 else nan;
def ArDn     =   if !arrows or Hold[0] == Hold[1] then nan else if Hold[0] == -1 then line2 else nan;
def LBUp     =   if fill and Hold[0] == 1 then line2 else nan;
def UBUp     =   if fill and Hold[0] == 1 then line1 else nan;
def LBDn     =   if fill and Hold[0] == -1 then line2 else nan;
def UBDn     =   if fill and Hold[0] == -1 then line1 else nan;
def AlertUp  =   alerts and Hold[1] ==  1 and (Hold[1] <> Hold[2]);
def AlertDn  =   alerts and Hold[1] == -1 and (Hold[1] <> Hold[2]);

#Colors
DefineGlobalColor("Cloud Up", Color.DARK_GREEN);
DefineGlobalColor("Cloud Dn", Color.DARK_RED);
DefineGlobalColor("Channel Up", Color.GREEN);
DefineGlobalColor("Channel Down", Color.RED);
DefineGlobalColor("Price Up", Color.GREEN);
DefineGlobalColor("Price Neutral", Color.GRAY);
DefineGlobalColor("Price Down", Color.RED);

#Plots
plot UB = line1;
UB.SetLineWeight(1);
UB.AssignValueColor(if Hold[0] == 1 then GlobalColor("Channel Up")
else GlobalColor("Channel Down"));
plot LB = line2;
LB.SetLineWeight(1);
LB.AssignValueColor(if Hold[0] == 1 then GlobalColor("Channel Up")
else GlobalColor("Channel Down"));
plot BOA = ArUp;
BOA.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BOA.SetDefaultColor(Color.GREEN);
BOA.SetLineWeight(2);
plot BDA = ArDn;
BDA.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
BDA.SetDefaultColor(Color.RED);
BDA.SetLineWeight(2);

#Clouds
AddCloud(LBUp, UBUp, GlobalColor("Cloud Up"), GlobalColor("Cloud Dn"));
AddCloud(LBDn, UBDn, GlobalColor("Cloud Dn"), GlobalColor("Cloud Up"));

#Price Color
AssignPriceColor(if pricecolor then if close > line2 then GlobalColor("Price Up")
else if close < line1 then GlobalColor("Price Down")
else GlobalColor("Price Neutral")
else Color.CURRENT);

# --- End code ---
Super interesting study. I am going to try it and thanks. Joe

Momentum Bollinger Band channels indicator for TOS Thinkscript Thinkorswim

(Based of Pensar's Keltner channel Momentum which is based on which is based on FW-MOBO-Advanced https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/E-F/FW-MOBO-Advanced) as per @acjtumio1987 request

Remember to Thumbs up if you found this post useful

Code:
#Momentum Bollinger band channel v1.0 by XeoNoX via usethinkscript.com
#Request 03-16-2021
#Based of Pensar's Keltner channel Momentum bands via usethinkscript.com
#Inputs
input factor       =     0.5;
input price        =     close;
input type         =     AverageType.SIMPLE;
input pricecolor   =     yes;
input fill         =     yes;
input arrows       =     yes;
input sound        =     {default "Ding", "Bell", "Chimes", "NoSound", "Ring"};
input displace = 0;
input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.SIMPLE;

def sDev = StDev(data = price[-displace], length = length);

#Variables
def nan      =   Double.NaN;
def shift    =   factor * MovingAverage(type, TrueRange(high, close, low), length);
plot avg     = MovingAverage(averageType, data = price[-displace], length = length);
def line1    =   avg + Num_Dev_Dn * sDev;
def line2    =    avg + Num_Dev_up * sDev;
def Chg      =   If(close > line2, 1, If(close < line1, -1, 0));
def Hold     =   CompoundValue(1, If(Hold[1] == Chg or Chg == 0, Hold[1], If(Chg == 1, 1, -1)), 0);
def ArUp     =   if !arrows or Hold[0] == Hold[1] then nan else if Hold[0] == 1 then line1 else nan;
def ArDn     =   if !arrows or Hold[0] == Hold[1] then nan else if Hold[0] == -1 then line2 else nan;
def LBUp     =   if fill and Hold[0] == 1 then line2 else nan;
def UBUp     =   if fill and Hold[0] == 1 then line1 else nan;
def LBDn     =   if fill and Hold[0] == -1 then line2 else nan;
def UBDn     =   if fill and Hold[0] == -1 then line1 else nan;
def AlertUp  =   alerts and Hold[1] ==  1 and (Hold[1] <> Hold[2]);
def AlertDn  =   alerts and Hold[1] == -1 and (Hold[1] <> Hold[2]);

#Colors
DefineGlobalColor("Cloud Up", Color.DARK_GREEN);
DefineGlobalColor("Cloud Dn", Color.DARK_RED);
DefineGlobalColor("Channel Up", Color.GREEN);
DefineGlobalColor("Channel Down", Color.RED);
DefineGlobalColor("Price Up", Color.GREEN);
DefineGlobalColor("Price Neutral", Color.GRAY);
DefineGlobalColor("Price Down", Color.RED);

#Plots
plot UB = line1;
UB.SetLineWeight(1);
UB.AssignValueColor(if Hold[0] == 1 then GlobalColor("Channel Up")
else GlobalColor("Channel Down"));
plot LB = line2;
LB.SetLineWeight(1);
LB.AssignValueColor(if Hold[0] == 1 then GlobalColor("Channel Up")
else GlobalColor("Channel Down"));
plot BOA = ArUp;
BOA.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BOA.SetDefaultColor(Color.GREEN);
BOA.SetLineWeight(2);
plot BDA = ArDn;
BDA.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
BDA.SetDefaultColor(Color.RED);
BDA.SetLineWeight(2);

#Clouds
AddCloud(LBUp, UBUp, GlobalColor("Cloud Up"), GlobalColor("Cloud Dn"));
AddCloud(LBDn, UBDn, GlobalColor("Cloud Dn"), GlobalColor("Cloud Up"));

#Price Color
AssignPriceColor(if pricecolor then if close > line2 then GlobalColor("Price Up")
else if close < line1 then GlobalColor("Price Down")
else GlobalColor("Price Neutral")
else Color.CURRENT);

# --- End code ---
Hi XeoNoX,

How might I make the two alerts into watchlists columns, which change to the corresponding cloud color when triggered?

@CT88 I do not use this indicator, so I can't guarantee that I got this right. But give it a shot.

Ruby:
##  WATCHLIST ONLY ##
#Momentum Bollinger band channel v1.0 by XeoNoX via usethinkscript.com
#Request 03-16-2021
#Based of Pensar's Keltner channel Momentum bands via usethinkscript.com
#Inputs
input factor       =     0.5;
input price        =     close;
input type         =     AverageType.SIMPLE;
input pricecolor   =     yes;
input fill         =     yes;
input arrows       =     yes;
input sound        =     {default "Ding", "Bell", "Chimes", "NoSound", "Ring"};
input displace = 0;
input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.SIMPLE;

def sDev = StDev(data = price[-displace], length = length);

#Variables
def nan      =   Double.NaN;
def shift    =   factor * MovingAverage(type, TrueRange(high, close, low), length);
def avg     = MovingAverage(averageType, data = price[-displace], length = length);
def line1    =   avg + Num_Dev_Dn * sDev;
def line2    =    avg + Num_Dev_up * sDev;
def Chg      =   If(close > line2, 1, If(close < line1, -1, 0));
def Hold     =   CompoundValue(1, If(Hold[1] == Chg or Chg == 0, Hold[1], If(Chg == 1, 1, -1)), 0);
def ArUp     =   if !arrows or Hold[0] == Hold[1] then nan else if Hold[0] == 1 then line1 else nan;
def ArDn     =   if !arrows or Hold[0] == Hold[1] then nan else if Hold[0] == -1 then line2 else nan;
def LBUp     =   if fill and Hold[0] == 1 then line2 else nan;
def UBUp     =   if fill and Hold[0] == 1 then line1 else nan;
def LBDn     =   if fill and Hold[0] == -1 then line2 else nan;
def UBDn     =   if fill and Hold[0] == -1 then line1 else nan;
def AlertUp  =   alerts and Hold[1] ==  1 and (Hold[1] <> Hold[2]);
def AlertDn  =   alerts and Hold[1] == -1 and (Hold[1] <> Hold[2]);

#Plots
def UB = line1;
def LB = line2;
plot BOA = ArUp;
def BDA = ArDn;

if AlertDN then "Breakdown" else  "none");

if AlertDn then color.red   else color.gray);

# --- End code ---

87k+ Posts
339 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?