Author: Copyright @ 2011, downspin
BBR

This trading tool is designed to identify potential reversal points in the market by combining two well-known technical analysis methods: Bollinger Bands and the Relative Strength Index (RSI). Instead of simply looking for price movements in isolation, this script looks for specific "exhaustion" signals where the market appears to be overextended and likely to turn around.

How the Logic Works

The tool monitors three specific conditions simultaneously to generate buy and sell signals:

1. Price Volatility (Bollinger Bands) The script tracks whether the price has pushed outside of the normal trading range defined by Bollinger Bands. It looks for instances where the price "breaks out" too far in one direction, suggesting that the current trend may be overextended.

2. Market Momentum (Relative Strength Index) To avoid entering a trade during a strong, healthy trend, the script uses the RSI to measure momentum. It identifies "oversold" conditions (where the market may be ready for a bounce up) and "overbought" conditions (where the market may be ready to drop).

3. The Reversal Confirmation This is the most critical part of the logic. A signal is only triggered if all three of the following elements align:

  • For a Buy Signal (Green Arrow): The price must have dropped below the lower Bollinger Band, the RSI must show that the market is in an oversold state, and—most importantly—the RSI must start to tick upward, indicating that the downward momentum is losing steam.

  • For a Sell Signal (Red Arrow): The price must have risen above the upper Bollinger Band, the RSI must show that the market is in an overbought state, and the RSI must start to tick downward, indicating that the upward momentum is beginning to fade.

Visual Feedback

To make the chart easier to read at a glance, the script provides dynamic color-coded labels:

  • Status Labels: It displays "RSI" and "BB" indicators on your screen. These change colors dynamically based on the current market state (e.g., turning Green or Red when specific price or momentum thresholds are breached).
  • On-Chart Arrows: When the specific combination of a price breakout, an overextended RSI value, and a confirmed momentum shift occurs, the script places a visual arrow on the chart to highlight the entry point for the trader.
Indicators Used
Relative strength indexBollinger bands indicator
Miscellaneous
Implements a curve of type %1
16 Views
1 Downloads
0 Favorites
BBR
//+------------------------------------------------------------------+
//|                                                          BBR.mq4 |
//|          Bollinger Bands Breakout Reversal with RSI confirmation |
//+------------------------------------------------------------------+
#property copyright "Copyright @ 2011, downspin"
#property link      "mg@downspin.de"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 DarkSlateGray

extern int corner=0,
           x_dist=3,
           y_dist=10;

double up[],
       down[];

int init(){
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0, 233); SetIndexBuffer(0,up);
   SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1, 234); SetIndexBuffer(1,down);
   return(0);
}
int deinit(){
  ObjectDelete("rsi");
  ObjectDelete("bb");
  return(0);
}
int start(){
  double rsi0,rsi1,rsi2,bbu0,bbu1,bbl0,bbl1;
  color rsicol=indicator_color3,
        bbcol=indicator_color3;
  for(int i=Bars;i>=0;i--){
    rsi0=iRSI(Symbol(),0,7,5,i);
    rsi1=iRSI(Symbol(),0,7,5,i+1);
    rsi2=iRSI(Symbol(),0,7,5,i+2);
    bbu0=iBands(Symbol(),0,20,2,1,0,1,i);
    bbu1=iBands(Symbol(),0,20,2,1,0,1,i+1);
    bbl0=iBands(Symbol(),0,20,2,1,0,2,i);
    bbl1=iBands(Symbol(),0,20,2,1,0,2,i+1);
    if((Low[i+1]<bbl1||Low[i]<bbl0)&&(rsi1<20||rsi2<20)&&rsi0>rsi1){
      up[i]=Low[i]-5*Point;
    }
    if((High[i+1]>bbu1||High[i]>bbu0)&&(rsi1>80||rsi2>80)&&rsi0<rsi1){
      down[i]=High[i]+5*Point;
    }
    if(i==0){
      if(rsi0<20||rsi1<20||rsi2<20||rsi0>80||rsi1>80||rsi2>80) rsicol=Orange;
      if((rsi1<20||rsi2<20)&&rsi0>rsi1) rsicol=Green;
      if((rsi1>80||rsi2>80)&&rsi0<rsi1) rsicol=Red;
      if(High[i]>bbu0||High[i+1]>bbu1) bbcol=Red;
      if(Low[i]<bbl0||Low[i+1]<bbl1) bbcol=Green;
      ObjectCreate("rsi", OBJ_LABEL, 0, 0, 0);
      ObjectSetText("rsi","RSI",8, "Arial Bold", rsicol);
      ObjectSet("rsi", OBJPROP_CORNER, 0);
      ObjectSet("rsi", OBJPROP_XDISTANCE, x_dist);
      ObjectSet("rsi", OBJPROP_YDISTANCE, y_dist);
      ObjectCreate("bb", OBJ_LABEL, 0, 0, 0);
      ObjectSetText("bb","BB",8, "Arial Bold", bbcol);
      ObjectSet("bb", OBJPROP_CORNER, 0);
      ObjectSet("bb", OBJPROP_XDISTANCE, x_dist+23);
      ObjectSet("bb", OBJPROP_YDISTANCE, y_dist);
    }
  }
  return(0);
}

Comments