Percent Bollinger Bands

Download script
Author: ��� ����� �. aka KimIV
Percent Bollinger Bands

This tool provides a unique visual representation of price action by calculating the relative position of the current market price within a specific range. Instead of simply showing you where the price is, it translates that price into a percentage-based value, making it easier to identify where the market sits in relation to its recent highs and lows.

How the Logic Works

1. Establishing the Boundaries The script begins by looking at a specific window of past data (determined by the "MA_Period" setting). Within this timeframe, it identifies the upper and lower boundaries of price movement. It calculates these boundaries based on standard volatility measures, creating a defined "envelope" or corridor for the market.

2. Measuring the Price Position Once these upper and lower boundaries are established, the script looks at the most recent closing price. It then performs a mathematical calculation to see where that closing price sits between the two boundaries.

3. Converting to a Percentage Scale The core logic takes the distance between the current price and the bottom boundary and compares it to the total height of the entire range (the distance from the bottom boundary to the top). This is then expressed as a numerical value.

What this means for the user

Instead of looking at raw price numbers, this indicator gives you a normalized view of market momentum:

  • High Values: When the resulting number is near the top of its range, it indicates that the price is trading very close to its recent highs (approaching the upper boundary).
  • Low Values: When the resulting number is near the bottom, it suggests the price is trading very close to its recent lows (approaching the lower boundary).
  • Middle Values: A value centered in the range indicates that the price is hovering in the middle of its recent volatility corridor.

By using this logic, the indicator simplifies complex price movements into a clear, readable scale that helps highlight whether the market is currently "overextended" or "undervalued" relative to its recent history.

Indicators Used
Bollinger bands indicator
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
Percent Bollinger Bands
//+------------------------------------------------------------------+
//|                                      Percent Bollinger Bands.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"

#property indicator_separate_window
//---- input parameters
extern int MA_Period=20;
extern int Deviation=2;
//---- indicator buffers
double ExtMapBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() {
  SetIndexStyle(0, DRAW_LINE);
  IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS));
  SetIndexBuffer(0, ExtMapBuffer);
  return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
  int i, counted_bars = IndicatorCounted();
  double dn, up;
  if(Bars<=MA_Period) return(0);
//---- check for possible errors
  if (counted_bars<0) return(-1);
//---- last counted bar will be recounted
  if (counted_bars>0) counted_bars--;
//---- 
  i = Bars - MA_Period - 1;
  if(counted_bars>=MA_Period) i = Bars - counted_bars - 1;
  while(i>=0) {
    dn = iBands(NULL,0,MA_Period,Deviation,0,PRICE_LOW,MODE_LOWER,i);
    up = iBands(NULL,0,MA_Period,Deviation,0,PRICE_HIGH,MODE_UPPER,i);
    ExtMapBuffer[i] = (Close[i] - dn) / (up - dn);
    i--;
  }
//----
  return(0);
}
//+------------------------------------------------------------------+

Comments