This tool is designed to provide traders with a visual representation of market momentum and volatility by analyzing the relationship between current price action and historical averages. Instead of looking at prices directly on a main chart, this script creates a separate window that translates complex market movements into four distinct data streams.
Core Logic Overview
The script functions by calculating several key financial metrics simultaneously to give a complete picture of the market's "pulse." Here is how it processes information:
- Price Positioning: The tool first determines the average price over a specific number of recent candles (defined by the user). It then measures how far the current closing price sits above or below this average. This helps identify whether the market is currently overextended or returning to its "normal" state.
- Volatility Boundaries: The script calculates the "Standard Deviation," which is a mathematical way of measuring how much the price swings up and down. By multiplying this by a specific factor, the tool establishes upper and lower boundaries.
- The Upper Boundary represents a zone where prices may be reaching an extreme high relative to recent history.
- The Lower Boundary represents an extreme low.
- Dynamic Mapping: These calculations are combined to create four distinct visual lines on your screen:
- The distance between the current price and the moving average.
- The upper volatility limit.
- The lower volatility limit.
- A baseline of zero (the equilibrium point).
How it helps the trader
By visualizing these four components together, the tool allows you to see more than just where the price is; it shows you how "stretched" the market is.
When the data points move significantly toward the outer boundaries, it signals high volatility or potential exhaustion in the current trend. Conversely, when the lines contract toward the center, it suggests a period of stability or consolidation. This allows traders to identify potential turning points and measure the intensity of market movements in real-time.
//+------------------------------------------------------------------+
//| 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