Rsi_Bands_B

Download script
Author: Copyright � 2010, basisforex@gmail.com
Rsi_Bands_B

The Rsi_Bands_B script is a technical analysis tool designed to provide visual cues on a trading chart by combining price movement averages with momentum indicators. Rather than simply showing a single line, it creates a dynamic "band" or range that helps traders identify the strength and direction of current market trends.

How the Logic Works

The tool functions by calculating three primary components simultaneously:

1. The Baseline (Moving Average) The script first establishes a central reference point using a customized moving average. To ensure this baseline is accurate, it doesn't just look at closing prices; it takes into account the high, low, and close prices of a specific number of past candles (the "period"). This provides a smoothed representation of the "fair value" of the asset over time.

2. The Momentum Factor (RSI) The script then incorporates the Relative Strength Index (RSI), which measures how quickly and strongly an asset's price is moving. By using a weighted version of this calculation, the tool can sense whether the market is experiencing "over mua" or "oversold" conditions, as well as the velocity of those movements.

3. The Dynamic Deviation (Volatility) To make the bands react to actual market conditions, the script calculates volatility (how much the price swings). This ensures that the bands expand during high-activity periods and contract during quieter markets, preventing the indicator from becoming "static" or irrelevant during different market phases.

How it Translates to the Chart

The visual output on your chart is determined by comparing the current price action against the baseline:

  • Bullish Momentum: If the price is trading above the baseline and shows upward strength, the script calculates an upper boundary. It adds a value to the baseline based on the current RSI momentum. This creates an upper "ceiling" that follows the trend.
  • Bearish Momentum: If the price is trading below the baseline and showing downward strength, the script calculates a lower boundary. It subtracts a value from the baseline (using the inverse of the RSI momentum) to create a floor.
  • Neutral Phase: When the price is hovering closely around the baseline without clear directional strength, the indicator remains centered on the moving average.

Summary for Traders

Essentially, this script acts as a "trend tracker" with adjustable boundaries. It helps you visualize not just where the price has been, but also how much momentum is currently pushing the price away from its average. It provides a cleaner, more integrated way to see market sentiment compared to looking at standard RSI or Moving Average indicators in isolation.

Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains close prices for each bar
Indicators Used
Relative strength indexIndicator of the average true range
Miscellaneous
Implements a curve of type %1
5 Views
0 Downloads
0 Favorites
Rsi_Bands_B
/*------------------------------------------------------------------+
 |                                                  Rsi_Bands_B.mq4 |
 |                                                 Copyright © 2010 |
 |                                             basisforex@gmail.com |
 +------------------------------------------------------------------*/
#property copyright "Copyright © 2010, basisforex@gmail.com"
#property link      "basisforex@gmail.com"
//-----
#property indicator_chart_window
#property indicator_buffers  2
#property indicator_color1   Blue
#property indicator_color2   Yellow
//-----
extern    int       nPeriod     = 13;
extern    int       MaShift     = 0;
//-----
double    Deviation, r;
double    MaBuffer[];
double    RSIBuffer[];
//+------------------------------------------------------------------+
int init()
 {
   SetIndexShift(0, MaShift);
   SetIndexShift(1, MaShift);
   //-----
   SetIndexBuffer(0, MaBuffer);
   SetIndexBuffer(1, RSIBuffer);
   //-----
   SetIndexStyle(0, DRAW_LINE, STYLE_DOT);
   SetIndexStyle(1, DRAW_LINE);
   //-----
   SetIndexLabel(0, "MA");
   SetIndexLabel(1, "RSI");
   //-----
   return(0);
 }
//+------------------------------------------------------------------+
int start()
 {
   int limit;
   double a;
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0) return(-1);
   if(counted_bars > 0) counted_bars--;
   limit = Bars - counted_bars;
   for(int i = 0; i < limit; i++)
    {
      a = 0;
      for(int j = 0; j < nPeriod; j++)
       {
         a = a + (iHigh(NULL, 0, i + j) + iLow(NULL, 0, i + j) + iClose(NULL, 0, i + j) * 2) / 4;
       }       
      MaBuffer[i]  =  a / nPeriod;
      //-----      
      r = iRSI(NULL, 0, nPeriod, PRICE_WEIGHTED, i);
      Deviation = iATR(NULL, 0, nPeriod, i) * 300;
      //-----
      if(iHigh(NULL, 0, i) > MaBuffer[i] && iClose(NULL, 0, i) > MaBuffer[i])
       {
         RSIBuffer[i] = MaBuffer[i] + r * Point * Deviation;
       }  
      else if(iLow(NULL, 0, i) < MaBuffer[i] && iClose(NULL, 0, i) < MaBuffer[i])
       {
         RSIBuffer[i] = MaBuffer[i] - (100 - r) * Point * Deviation;
       }
      else
       {
         RSIBuffer[i] = MaBuffer[i];
       }    
    }  
   //-----
   return(0);
 }
//+------------------------------------------------------------------+

/*      switch (Period())
       {
         case 1:
            Deviation = 0.236;
            break;
         case 5:
            Deviation = 0.5;
            break; 
         case 15:
            Deviation = 0.764;
            break; 
         case 30:
            Deviation = 1;
            break;
         case 60:
            Deviation = 1.618;
            break;
         case 240:
            Deviation = 2.618;
            break;
         case 1440:
            Deviation = 4.618;
            break;
         case 10080:
            Deviation = 10.618;
            break;
         case 43200:
            Deviation = 25.618;
            break;
       }                                 
*/   

Comments