Momentum Bollinger Band Channels for ThinkorSwim

XeoNoX

Expert
VIP
Lifetime
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

VvveIZH.jpg


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
#which is based on FW-MOBO-Advanced  https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/E-F/FW-MOBO-Advanced
#Inputs
input factor       =     0.5;
input price        =     close;
input type         =     AverageType.SIMPLE;
input pricecolor   =     yes;
input fill         =     yes;
input arrows       =     yes;
input alerts       =     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);

#Alerts
Alert(AlertUp, "BREAKOUT!",  Alert.BAR, Sound);
Alert(AlertDn, "BREAKDOWN!", Alert.BAR, Sound);

# --- End code ---
 
Last edited:
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

VvveIZH.jpg


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
#which is based on FW-MOBO-Advanced  https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/E-F/FW-MOBO-Advanced
#Inputs
input factor       =     0.5;
input price        =     close;
input type         =     AverageType.SIMPLE;
input pricecolor   =     yes;
input fill         =     yes;
input arrows       =     yes;
input alerts       =     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);

#Alerts
Alert(AlertUp, "BREAKOUT!",  Alert.BAR, Sound);
Alert(AlertDn, "BREAKDOWN!", Alert.BAR, Sound);

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

VvveIZH.jpg


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
#which is based on FW-MOBO-Advanced  https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/E-F/FW-MOBO-Advanced
#Inputs
input factor       =     0.5;
input price        =     close;
input type         =     AverageType.SIMPLE;
input pricecolor   =     yes;
input fill         =     yes;
input arrows       =     yes;
input alerts       =     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);

#Alerts
Alert(AlertUp, "BREAKOUT!",  Alert.BAR, Sound);
Alert(AlertDn, "BREAKDOWN!", Alert.BAR, Sound);

# --- 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.
a2.png

Shared Watchlist Link: http://tos.mx/behZa96 Click here for --> Easiest way to load shared links


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
#which is based on FW-MOBO-Advanced  https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/E-F/FW-MOBO-Advanced
#Inputs
input factor       =     0.5;
input price        =     close;
input type         =     AverageType.SIMPLE;
input pricecolor   =     yes;
input fill         =     yes;
input arrows       =     yes;
input alerts       =     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;

AddLabel(yes,
if AlertUp then "Breakout" else
if AlertDN then "Breakdown" else  "none");
          
AssignBackgroundColor(if AlertUp then color.green else
                      if AlertDn then color.red   else color.gray);

# --- End code ---
 

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