Modified Bollinger Bands

Modified Bollinger Bands

Download

Product Description

Very simple modification to the bollinger bands indicator, removing the middle line (moving average) and leaving only the outer support and resistance bands.

ModifiedBollingerBands.mq4 (Currently Viewing)
//+------------------------------------------------------------------+
//|                                     Modified Bollinger Bands.mq4 |
//|     This tool allows you to use bollinger band support           |
//|     and resistance without the moving average.                   |
//|     More free tools @ tradertools-fx.com                         |
//|                                           Paul Nordin            |    
//|                                           www.tradertools-fx.com |
//+------------------------------------------------------------------+
#property copyright "© 2011 TradertoolsFX"
#property link      "www.tradertools-fx.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red

// User Parameters
extern int   period = 20;
extern int   numDeviations = 2;
extern int   bandsShift = 0;
extern int   appliedPrice = 0;

double upperBand[], lowerBand[];

int init() {

   SetIndexShift( 0, appliedPrice );
   SetIndexShift( 1, appliedPrice );

   SetIndexBuffer( 0, upperBand );
   SetIndexBuffer( 1, lowerBand );
  
   SetIndexStyle( 0, DRAW_LINE );
   SetIndexStyle( 1, DRAW_LINE );
  
   SetIndexLabel( 0, "Upper Band" );
   SetIndexLabel( 1, "Lower Band" );
   
   return(0);
}

int start() {

   int numBars = IndicatorCounted();
   
   if ( numBars < 0 ) {
      return( -1 );
   }
   
   if ( numBars > 0 ) {
      numBars--;
   }
   
   int limit = Bars - numBars;
   for ( int i = 0; i < limit; i++ ) {
      upperBand[i] = iBands( NULL, 0, period, numDeviations, 0, appliedPrice, MODE_UPPER, i );
      lowerBand[i] = iBands( NULL, 0, period, numDeviations, 0, appliedPrice, MODE_LOWER, i );
   }  
   
   return(0);
}