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