Any way to take this script and take out the RSI portion? Just need the indicator to signal when price crosses or touches the upper or lower Bollinger Bands regardless of what RSI is. Price does not have to close above/below the bands, just needs to cross or touch them. Any help would be greatly appreciated!
#bb_rsi_colors
#https://usethinkscript.com/threads/bollinger-band-with-rsi.17083/
#Bollinger Band with RSI
#Indicator:
#Bollinger Band Setting 30 with 2 deviation.
#Regular RSI.
#Criteria:
#for Short:
#When the price is over the bollinger band top and the RSI is over 70 then assign a RED candles and plot a red arrow.
#for LONG:
#When the price is under the bollinger band bottom and the RSI is under 30 then assign a Green candles an plot a green arrow.
#if is not either criteria keep the candles gray color.
def na = double.nan;
def bn = barnumber();
input price = close;
input color_the_bars = yes;
input show_arrows = yes;
#-----------------------------
# BB
#input price = close;
#input displace = 0;
input bb_length = 30;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input bb_avg_type = AverageType.SIMPLE;
def sDev = StDev(price, bb_length);
def MidLine = MovingAverage(bb_avg_type, price, bb_length);
def LowerBand = MidLine + Num_Dev_Dn * sDev;
def UpperBand = MidLine + Num_Dev_up * sDev;
input show_bb_lines = yes;
plot zbbup = if show_bb_lines then upperband else na;
plot zbbmid = if show_bb_lines then midline else na;
plot zbblo = if show_bb_lines then lowerband else na;
zbbup.SetDefaultColor(GetColor(5));
zbbmid.SetDefaultColor(GetColor(1));
zbblo.SetDefaultColor(GetColor(0));
#-------------------------------
# rsi
input rsi_len = 14;
input rsi_over_bought = 70;
input rsi_over_Sold = 30;
input rsi_avg_type = AverageType.WILDERS;
def NetChgAvg = MovingAverage(rsi_avg_type, price - price[1], rsi_len);
def TotChgAvg = MovingAverage(rsi_avg_type, AbsValue(price - price[1]), rsi_len);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
#------------------------------
def long_rule1 = (close < lowerband);
def long_rule2 = (rsi < rsi_over_Sold);
def short_rule1 = (close > upperband);
def short_rule2 = (rsi > rsi_over_bought);
def long = long_rule1 and long_rule2;
def short = short_rule1 and short_rule2;
#------------------------------
def y = 0.002;
plot zlong = if show_arrows and long then (low * (1 - y)) else na;
zlong.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zlong.SetDefaultColor(Color.green);
zlong.setlineweight(1);
zlong.hidebubble();
plot zshort = if show_arrows and short then (high * (1 + y)) else na;
zshort.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zshort.SetDefaultColor(Color.red);
zshort.setlineweight(1);
zshort.hidebubble();
#------------------------------
AssignPriceColor(if !color_the_bars then color.current
else if long then color.green
else if short then color.red
else color.gray);
#bb_rsi_colors
#https://usethinkscript.com/threads/bollinger-band-with-rsi.17083/
#Bollinger Band with RSI
#Indicator:
#Bollinger Band Setting 30 with 2 deviation.
#Regular RSI.
#Criteria:
#for Short:
#When the price is over the bollinger band top and the RSI is over 70 then assign a RED candles and plot a red arrow.
#for LONG:
#When the price is under the bollinger band bottom and the RSI is under 30 then assign a Green candles an plot a green arrow.
#if is not either criteria keep the candles gray color.
def na = double.nan;
def bn = barnumber();
input price = close;
input color_the_bars = yes;
input show_arrows = yes;
#-----------------------------
# BB
#input price = close;
#input displace = 0;
input bb_length = 30;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input bb_avg_type = AverageType.SIMPLE;
def sDev = StDev(price, bb_length);
def MidLine = MovingAverage(bb_avg_type, price, bb_length);
def LowerBand = MidLine + Num_Dev_Dn * sDev;
def UpperBand = MidLine + Num_Dev_up * sDev;
input show_bb_lines = yes;
plot zbbup = if show_bb_lines then upperband else na;
plot zbbmid = if show_bb_lines then midline else na;
plot zbblo = if show_bb_lines then lowerband else na;
zbbup.SetDefaultColor(GetColor(5));
zbbmid.SetDefaultColor(GetColor(1));
zbblo.SetDefaultColor(GetColor(0));
#-------------------------------
# rsi
input rsi_len = 14;
input rsi_over_bought = 70;
input rsi_over_Sold = 30;
input rsi_avg_type = AverageType.WILDERS;
def NetChgAvg = MovingAverage(rsi_avg_type, price - price[1], rsi_len);
def TotChgAvg = MovingAverage(rsi_avg_type, AbsValue(price - price[1]), rsi_len);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
#------------------------------
def long_rule1 = (close < lowerband);
def long_rule2 = (rsi < rsi_over_Sold);
def short_rule1 = (close > upperband);
def short_rule2 = (rsi > rsi_over_bought);
def long = long_rule1 and long_rule2;
def short = short_rule1 and short_rule2;
#------------------------------
def y = 0.002;
plot zlong = if show_arrows and long then (low * (1 - y)) else na;
zlong.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zlong.SetDefaultColor(Color.green);
zlong.setlineweight(1);
zlong.hidebubble();
plot zshort = if show_arrows and short then (high * (1 + y)) else na;
zshort.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zshort.SetDefaultColor(Color.red);
zshort.setlineweight(1);
zshort.hidebubble();
#------------------------------
AssignPriceColor(if !color_the_bars then color.current
else if long then color.green
else if short then color.red
else color.gray);
Last edited: