i-BandsPrice

Download script
Author: Copyright � 2008, Talex
i-BandsPrice

The i-BandsPrice indicator is a specialized technical analysis tool designed to measure where the current market price sits relative to its recent volatility. Instead of simply showing you "high" and "low" price boundaries, this script calculates a normalized value—essentially a percentage or ratio—to help traders visualize how far the market has stretched away from its average movement.

How the Logic Works

The indicator operates through a multi-step mathematical process to translate raw price data into a readable signal:

1. Establishing the Baseline (The Average) First, the script looks back at a specific number of previous candles (the "Period") to calculate a Simple Moving Average. This represents the "fair value" or the center point of the market's recent activity.

2. Measuring the Spread (Volatility) Next, the tool calculates the difference between each individual candle's closing price and that baseline average. It squares these differences to find the "standard deviation." In simpler terms, it is measuring how much the price is "swinging" or "jittering" around its average. A high swing creates a wide spread; a tight, stable market creates a narrow spread.

3. Calculating the Upper and Lower Boundaries Using these measurements, the script establishes two invisible boundaries: an Upper Band and a Lower Band. These bands act like a rubber band—they expand when the market is volatile and contract when the market is calm.

4. Normalizing the Price (The Final Output) This is where the tool differs from standard Bollinger Bands. Rather than plotting the lines themselves, the script takes the current price and calculates its position between those two boundaries.

  • If the price is exactly in the middle of the bands, it produces a mid-point value.
  • As the price moves toward the top boundary, the value increases.
  • As it moves toward the bottom boundary, the value decreases.

5. Smoothing the Signal To ensure the data is easy to read and not "noisy" or jumpy, the script applies one final smoothing pass over these values. This creates a continuous line that highlights the prevailing trend of the price's position relative to its volatility limits.

Practical Summary

By using this logic, you aren't just looking at where the price is; you are looking at how stretched the price is compared to its own historical behavior. It tells you whether the market is currently overextended toward the highs or lows relative to its recent "normal" range.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
i-BandsPrice
//+------------------------------------------------------------------+
//|                                                 i-BandsPrice.mq4 |
//|                                          Copyright © 2008, Talex |
//|                                                 tan@gazinter.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Talex"
#property link      "tan@gazinter.net"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Yellow
#property indicator_level1 0
#property indicator_level2 0.25
#property indicator_level3 0.5
#property indicator_level4 0.75
#property indicator_level5 1

extern int    BandsPeriod=20;
extern int    BandsShift=0;
extern double BandsDeviations=2.0;
extern int    Slow=5;

double BPBuffer[],Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void init() {
   
   IndicatorBuffers(2);
   IndicatorShortName("i-BandsPrice ("+BandsPeriod+", "+DoubleToStr(BandsDeviations,1)+", "+Slow+")");
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Buffer);
   SetIndexBuffer(1,BPBuffer);
   
   return;
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void deinit() {

   return;
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
void start() {
   int i,j,limit,cbars;
   double sum,oldval,newres,deviation,upband,dwband;
   
   cbars=IndicatorCounted();
   if(Bars<=BandsPeriod) return;
   if(cbars<0) return;
   if(cbars>0) limit=Bars-cbars-1;
      else limit=Bars-BandsPeriod-1;

   for(i=0;i<=limit;i++) {
      sum=0.0;
      oldval=iMA(NULL,0,BandsPeriod,BandsShift,MODE_SMA,PRICE_CLOSE,i);
      for(j=0;j<BandsPeriod;j++) {
         newres=Close[i+j]-oldval;
         sum+=newres*newres;
      }
      deviation=BandsDeviations*MathSqrt(sum/BandsPeriod);
      upband=oldval+deviation;
      dwband=oldval-deviation;
      if((upband-dwband)!=0)
      BPBuffer[i]=(Close[i]-dwband)/(upband-dwband);
   }
   for(i=0;i<=limit;i++) {
      Buffer[i]=iMAOnArray(BPBuffer,0,Slow,0,0,i);
   }
   return;
}
//+------------------------------------------------------------------+

Comments