BBflat_sw

This tool is designed to provide a visual representation of price momentum and volatility by isolating specific mathematical components of market movement into a dedicated window. Instead of looking at the raw price chart, it calculates four distinct data points to help traders understand where the current price sits in relation to its historical average.

Core Logic and Components

The script operates by analyzing the relationship between the current market price and a moving average (a smoothed line that represents the "norm" of recent price action). It breaks this down into the following four layers:

1. The Deviation Bands (Upper and Lower Boundaries) The tool calculates a standard deviation, which measures how much the price typically fluctuates away from its average.

  • The Upper Band: Represents a high-volatility ceiling based on the chosen settings.
  • The Lower Band: Represents a corresponding floor. By plotting these, the indicator creates a "channel" of expected price movement. When price pushes toward or beyond these lines, it signals that the market is experiencing unusual activity compared to its recent history.

2. The Price Distance (Momentum) The script calculates the mathematical gap between the current closing price and the moving average. This is essentially a measure of "stretch." It tells you how far the price has pulled away from its equilibrium point.

How it Functions for the User

While standard indicators might simply show you a trend, this script isolates the intensity of that trend. By monitoring the distance between the actual price and the average, and comparing that to the calculated volatility bands, it allows you to see:

  • How "overextended" the market is at any given moment.
  • Whether current price movements are within the normal range of vibration or are becoming extreme.

In short, this script acts as a diagnostic tool that strips away the noise of the main chart to show you exactly how much pressure is being applied to the price relative to its historical average.

Indicators Used
Moving average indicatorStandard Deviation indicator
Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
BBflat_sw
//+------------------------------------------------------------------+
//|                                                    BBflat_sw.mq4 |
//|                                                          by Raff |
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Aqua
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Yellow
#property indicator_levelcolor  SlateGray
#property indicator_level1 0.0004
#property indicator_level2 -0.0004
extern int period=9;
extern int shift=0;
extern int method=0;
extern int price=0;
extern double deviation=1.5;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,ExtMapBuffer4);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
     int limit, counted_bars=IndicatorCounted();
     double ima, std;
     if(counted_bars<0) return(-1);
     if(counted_bars>0) counted_bars--;
     limit=Bars-counted_bars;
     for(int i=0; i<limit; i++)
       {
	    ima=iMA(NULL,0,period,shift,method,price,i);
       std=deviation*iStdDev(NULL,0,period,shift,method,price,i);
		 ExtMapBuffer1[i]=0;
       ExtMapBuffer2[i]=std;
       ExtMapBuffer3[i]=-std;
       ExtMapBuffer4[i]=Close[i]-ima;
       }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments