Bollinger bandswith Rsi ,Mfi, Rvol For ThinkOrSwim

Made this cuple of weeks ago thought i share Bolinger band with Rsi Mfi and rvol all in one

BImdFkx.png


Code:
# created by expertnoob365 aka ziz
# Bollinger Bands WITH
# RSI ENTERING AND EXITING OVER BOUGHT AND OVER SOLD (lower band  )
# MFI ENTERING AND EXITING OVER BOUGHT AND OVER SOLD (upper band)
# Dark green points entering over sold
# dark red points entering over bought
# cyan points  in over bought ot oversold
# Green  larger points EXITING OVER BOUGHT
# Red larger points EXITING OVER Sold
# rvol points  vol_To_Avg greater then 3 cyan, greater the 2.6 yellow, greater then 2.0 green, gteater then 1.6 dark orange (Mid Line)
#Added cussion cloudes 
#=    =    =    =    =    Rvol    =    =    =    =    = 
input Rvol_Type = AverageType.SIMPLE;
input RVol_Length = 10 ;
def rvolpaint = yes;
def rvol_color_id = yes;
def rvpoint = no;
def AvgVol = MovingAverage(rvol_Type, volume, RVol_length);
def vol_To_Avg = Round(volume / AvgVol);

def rv1 = 1.6;
def rv2 = 2.0;
def rv3 = 2.6;
def rv4 = 3.0;

def rv1x = vol_To_Avg > rv1 ;
def rv2x = vol_To_Avg > rv2 ;
def rv3x = vol_To_Avg > rv3;
def rv4x = vol_To_Avg > rv4;

#=    =    =    =    =    Bolinger-Bands    =    =    =    =    =
input BB_Type = AverageType.Simple;
input BB_Length = 20;
input BB_Price = close;

def  displace = 0;
def bbsDev = stdev(data = close[-displace], length = BB_length);

plot MidLine = MovingAverage(BB_Type, data = BB_Price[-displace], length = BB_length);

defineGlobalColor("MIDLINE" , (CreateColor(128,128,128)));
defineGlobalColor("cloud" , (CreateColor(128,128,128)));
defineGlobalColor("upper_cloud" , (CreateColor(128,128,128)));
defineGlobalColor("lower_cloud" , (CreateColor(128,128,128)));

MidLine.AssignValueColor(if  rv4x then Color.cyan else if  rv3x then Color.YELLOW else if rv2x then Color.GREEN else if  rv1x then Color.DARK_ORANGE else GlobalColor("MIDLINE"));
MidLine.HideBubble();
MidLine.SetStyle(Curve.POINTS);

def LowerBand = MidLine - 2 * bbsDev;
def UpperBand = MidLine + 2 * bbsDev;

INPUT Cussion_Clouds = YES;

addCloud(LowerBand, UpperBand, GlobalColor("cloud"),  GlobalColor("cloud"));

def upper_up_cloud = IF CUSSION_CLOUDS THEN  MidLine + 1.5 * bbsDev ELSE 0;
def upper_lo_cloud = IF CUSSION_CLOUDS THEN MidLine + 2.5 * bbsDev  ELSE 0;

addCloud(upper_up_cloud, upper_lo_cloud, GlobalColor("upper_cloud"),  GlobalColor("upper_cloud"));

def lower_up_cloud = IF CUSSION_CLOUDS THEN MidLine - 1.5 * bbsDev ELSE 0;
def lower_lo_cloud = IF CUSSION_CLOUDS THEN  MidLine - 2.5 * bbsDev ELSE 0;

addCloud(lower_up_cloud, lower_lo_cloud, GlobalColor("upper_cloud"),  GlobalColor("upper_cloud"));

#MidLine.AssignValueColor  (if Low <= LowerBand AND HL2 > LowerBand or  High >= UpperBand AND HL2 < UpperBand then COLOR.CYAN ELSE IF HL2 <= LowerBand or  HL2 >= UpperBand THEN COLOR.MAGENTA ELSE GlobalColor("MIDLINE"));

#=    =    =    =    =    MFI    =    =    =    =    =
input Mfi_Length = 10;
input Mfi_Over_Sold = 20;
input Mfi_Over_Bought = 80;

def mifmovingAvgLength = 1;
def mfi = Average(moneyflow(high, close, low, volume, Mfi_Length), mifmovingAvgLength);

DEF MIFCROSS_BElow20 = MFI CROSSES BElow Mfi_Over_Sold;#color.CYAN
DEF MFICROSS_above20 = MFI CROSSES above Mfi_Over_Sold;#color.GREEN
DEF MFICROSS_above80 = MFI CROSSES above Mfi_Over_Bought;#color.CYAN
DEF MFICROSS_BElow80 = MFI CROSSES BElow Mfi_Over_Bought;#color.red

defineGlobalColor("MFI" , (CreateColor(41,41,41)));#this hase to be transparrent

plot mfiUPPBand = MidLine + 2.0* bbsDev;
     mfiUPPBand.SetStyle(Curve.POINTS);
     mfiUPPBand.SETLineWeight(4);
     mfiUPPBand.AssignValueColor (  if  MFICROSS_above20 then color.GREEN else  if  MFICROSS_BElow80 then color.red else 
        GlobalColor("MFI"));

plot mfiUPPBandX = MidLine + 2.0* bbsDev;
     mfiUPPBandX.SetStyle(Curve.POINTS);
     mfiUPPBandX.SETLineWeight(1);
     mfiUPPBandX.AssignValueColor (
      if  MFICROSS_above80 then color.DARK_red else
      IF  MIFCROSS_BElow20 then color.DARK_GREEN else
      IF  mfi > Mfi_Over_Bought then color.CYAN else
      if  mfi < Mfi_Over_Sold then color.CYAN else
      GlobalColor("MFI"));

addLabel(yes, "MFI" , (if
    MIFCROSS_BElow20 then color.DARK_GREEN else if
    MFICROSS_above80 then color.DARK_red else
color.light_gray));

addLabel(yes, "      " , (
      IF  mfi > Mfi_Over_Bought then color.CYAN else
      if  mfi < Mfi_Over_Sold then color.CYAN else
color.light_gray));

addLabel(yes, round( mfi,0 ),(if
    MFICROSS_above20 then color.GREEN else if
    MFICROSS_BElow80 then color.red else
color.light_gray));

#=    =    =    =    =    RSI    =    =    =    =    =   
input Rsi_Type = AverageType.WILDERS;
input Rsi_Length = 14;

input Rsi_Over_Bought = 70;
input Rsi_Over_Sold = 30;

def NetChgAvg = MovingAverage(Rsi_Type, close - close[1], RSI_length);
def TotChgAvg = MovingAverage(Rsi_Type, AbsValue(close - close[1]), RSI_length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

DEF RSI = 50 * (ChgRatio + 1);
DEF RSICROSS_BElow30 = IF  RSI CROSSES BElow RSI_Over_Sold THEN 1 ELSE 0;#color.CYAN
DEF RSICROSS_above30 = IF RSI CROSSES above RSI_Over_Sold THEN 1 ELSE 0  ;#color.GREEN
DEF RSICROSS_above70 = IF  RSI CROSSES above RSI_over_Bought THEN 1 ELSE 0 ;#color.CYAN
DEF RSICROSS_BElow70 = IF RSI CROSSES BElow RSI_over_Bought THEN 1 ELSE 0  ;#color.red

plot RSIUPPBand = MidLine -2.0* bbsDev;
     RSIUPPBand.SetStyle(Curve.POINTS);
     RSIUPPBand.SETLineWeight(4);
     RSIUPPBand.AssignValueColor (
      if RSICROSS_above30 then color.GREEN else
      if RSICROSS_BElow70 then color.red else
      GlobalColor("MFI"));

plot RSIUPPBandX = MidLine - 2.0* bbsDev;
     RSIUPPBandX.SetStyle(Curve.POINTS);
     RSIUPPBandX.SETLineWeight(1);
     RSIUPPBandX.AssignValueColor (
      if  RSICROSS_above70 then color.DARK_red else
      IF  RSICROSS_BElow30 then color.DARK_GREEN else
      IF  RSI > RSI_over_Bought then color.CYAN else
      if  RSI < RSI_Over_Sold then color.CYAN
       else  GlobalColor("MFI"));

DEF RSI_BULL = RSICROSS_above30;
DEF RSI_BEAR = RSICROSS_BElow70;
DEF MFI_BULL = MFICROSS_ABOVE20;
DEF MFI_BEAR = MFICROSS_BElow80;


#=    =    =    =    =    lables    =    =    =    =    =   
addLabel(yes, "RSI" , (if
    RSICROSS_BElow30 then color.DARK_GREEN else if
    RSICROSS_ABove70 then color.DARK_red else
color.light_gray));

addLabel(yes, "      " , (
      IF  RSI > RSI_over_Bought then color.CYAN else
      if  RSI < RSI_Over_Sold then color.CYAN else
color.light_gray));

addLabel(yes, round( RSI,0 ),(if
    RSICROSS_above30 then color.GREEN else if
    RSICROSS_BElow70 then color.red else
color.light_gray));

AddLabel(rvol_color_id, RVol_length + "rV " +  vol_To_Avg,
  if vol_To_Avg > rv4 then Color.cyan else
  if vol_To_Avg > rv3 then Color.YELLOW else
  if vol_To_Avg > rv2 then Color.LIGHT_GREEN else
  if vol_To_Avg > rv1 then Color.DARK_ORANGE
  else Color.GRAY) ;



#=    =    =    =    =    Bubbles    =    =    =    =    =
input Bubbles = YES;
input Bubble_Mover  = -1;
DEF n1 = Bubble_Mover + 1;
input Rvol_Bubble_Mover  = 1;
def Rn1 = Rvol_Bubble_Mover +  1;
DEF RSIBand = MidLine - 2.1 * bbsDev;
DEF MFIBand = MidLine + 2.1 * bbsDev;
DEF RVOLbAND = MIDLINE;

AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[bubble_mover]) , RSIBand[N1],  "RSI",   CreateColor(160,160,0), NO);
AddChartBubble(bubbles and !IsNaN(close[RN1]) and IsNaN(close[Rvol_Bubble_Mover]) , RVOLbAND[RN1], "Rvol " ,  CreateColor(160,160,0), NO);
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[bubble_mover]) , MFIBand[N1],  "MFI",   CreateColor(160,160,0), YES);
 
Last edited:

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