Stochastic Bollinger Bands1

Download script
Stochastic Bollinger Bands1

This custom technical indicator is designed to provide traders with a unique visual tool that combines two popular market analysis methods: the Stochastic Oscillator and Bollinger Bands. By layering these two methodologies, the script aims to identify extreme price momentum and potential reversal points more clearly than using either tool alone.

How the Logic Works

The indicator operates through a two-step calculation process:

1. Establishing the Foundation (The Stochastic Layer) First, the script calculates a Stochastic value. In standard trading, the Stochastic Oscillator tracks the current price relative to its past price range to determine if an asset is "overbought" or "oversold." This serves as the primary data source for the indicator, capturing the underlying momentum of the market.

2. Applying Volatility Boundaries (The Bollinger Layer) Instead of applying Bollinger Bands directly to the main price chart (like a stock price or currency pair), this script applies them specifically to the Stochastic values calculated in the first step.

It creates three specific lines based on that data:

  • Upper and Lower Bands: These act as dynamic "envelopes" around the Stochastic momentum. They define the boundaries of what is considered "normal" volatility for the current momentum.
  • Middle Line: This provides a baseline, showing the average trend of the momentum.

What this means for the Trader

By wrapping the Stochastic Oscillator inside Bollinger Bands, the indicator creates a visual "channel" for momentum.

When the Stochastic line (the primary movement) pushes outside of the Bollinger Bands, it signals that the momentum is becoming unusually extreme. This setup helps traders identify moments where a trend might be overextended and due for a correction, providing a more nuanced view of market behavior than standard oscillators provide on their own.

Indicators Used
Stochastic oscillator
Miscellaneous
Implements a curve of type %1
16 Views
0 Downloads
0 Favorites
Stochastic Bollinger Bands1
#property  copyright "Copyright © 2007, Matt Edmonds."
#property  link      "matt.edmonds@gmail.com"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 4
#property  indicator_color1  Yellow
#property  indicator_color2  White
#property  indicator_color3  White
#property  indicator_color4  White



extern int StochasticPeriod=1;
extern int BollingerPeriod=10;
extern int BollingerDeviation = 1;
extern int BollingerShift = 0;

//---- indicator buffers
double Stochastic[];
double BollingerUpper[];
double BollingerLower[];
double BollingerMiddle[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(4);
   
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(3,DRAW_LINE,STYLE_DOT,1);
   
   SetIndexBuffer(0,Stochastic);
   SetIndexLabel(0,"Stochastic Bollinger Bands");
   SetIndexBuffer(1,BollingerUpper);
   SetIndexBuffer(2,BollingerLower);
   SetIndexBuffer(3,BollingerMiddle);
   SetIndexLabel(3,"Bollinger Middle");
      
//---- name for DataWindow and indicator subwindow label
 IndicatorShortName("Stochastic Bollinger Bands");
   
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Calculations                                    |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int i;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
 
//---- main loop
   for(i=0; i<Bars; i++)
   {
     Stochastic[i]= iStochastic(NULL, 0, StochasticPeriod, 1, 3, MODE_SMA, 0, MODE_MAIN, i);
    }
  
//---- done

   for(i=0; i<Bars; i++)
   {  
     BollingerLower[i] = iBandsOnArray(Stochastic,0,BollingerPeriod,BollingerDeviation,BollingerShift,MODE_LOWER,i); 
     BollingerUpper[i] = iBandsOnArray(Stochastic,0,BollingerPeriod,BollingerDeviation,BollingerShift,MODE_UPPER,i); 
     BollingerMiddle[i] = iBandsOnArray(Stochastic,0,BollingerPeriod,BollingerDeviation,BollingerShift,MODE_MAIN,i); 
   }   
   
   return(0);
  }
//+------------------------------------------------------------------+

Comments