VKW_Bands_modified
Download scriptThe VKW Bands indicator is designed to provide traders with a visual representation of price extremes by identifying and smoothing out key price boundaries. Rather than plotting directly on the main price chart, it operates in a separate window, allowing users to monitor market volatility and potential reversal zones more clearly.
Core Logic and Workflow
The tool operates through a multi-step calculation process that transforms raw data into actionable visual bands:
1. Data Retrieval The indicator begins by pulling external data from a secondary source (the "METRO" indicator). It uses this underlying data as the primary foundation for all subsequent calculations, ensuring that the bands are reacting to specific market movements identified by that base metric.
2. Identifying Extremes (Range Analysis) Once the base data is gathered, the script looks back over a specific timeframe defined by the "RangePeriod." Within this window, it automatically scans for two critical values:
- The Maximum: The highest point reached within that period.
- The Minimum: The lowest point reached within that period.
By identifying these peaks and valleys, the indicator establishes the "ceiling" and "floor" of the current market range.
3. Smoothing the Movement Raw highs and lows can often be jagged or "noisy," making them difficult to read accurately. To solve this, the script applies a moving average calculation to both the maximum and minimum values identified in the previous step. This smoothing process removes minor price fluctuations, resulting in fluid lines that represent the broader trend of the market's boundaries.
Visual Output
The final result is a set of smoothed bands (plotted in different colors like Blue and Red) that move with the market. These bands serve as dynamic boundaries:
- Upper Band: Represents the smoothed trajectory of recent price highs.
- Lower Band: Represents the smoothed trajectory of recent price lows.
By observing where the price interacts with these bands, traders can better visualize the range of the current market cycle and identify areas where the price may be reaching an exhausted state or beginning a new trend.
//+------------------------------------------------------------------+
//| VKW Bands.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Alksnis Gatis"
#property link "2xpoint@gmail.com"
//----
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 White
#property indicator_width2 2
//---- input parameters
extern int RangePeriod=25;
extern int SmoothPeriod=3;
extern int SmoothMode=MODE_SMA;
extern int Per=5;
//---- buffers
double ExtMapBuffer0[];
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//double ExtMapBuffer5[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(5);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexDrawBegin(0,SmoothPeriod);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexDrawBegin(1,SmoothPeriod);
SetIndexBuffer(2,ExtMapBuffer0);
SetIndexBuffer(3,ExtMapBuffer3);
SetIndexBuffer(4,ExtMapBuffer4);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
int limit,limit1,cnt,n_max,n_min;
if (counted_bars==0)
{
limit=Bars-RangePeriod;
limit1=limit-SmoothPeriod;
}
if (counted_bars>0)
{
limit=Bars-counted_bars;
limit1=limit;
}
limit--;
limit1--;
for(cnt=limit; cnt>=0;cnt--)
{
ExtMapBuffer0[cnt]=iCustom(NULL,0,"METRO",1,cnt);
}
for(cnt=limit; cnt>=0;cnt--)
{
n_max=ArrayMaximum(ExtMapBuffer0,RangePeriod,cnt);
n_min=ArrayMinimum(ExtMapBuffer0,RangePeriod,cnt);
ExtMapBuffer3[cnt]=ExtMapBuffer0[n_max];
ExtMapBuffer4[cnt]=ExtMapBuffer0[n_min];
}
for(cnt=limit1; cnt>=0;cnt--)
{
ExtMapBuffer1[cnt]=iMAOnArray(ExtMapBuffer3,0,SmoothPeriod,0,SmoothMode,cnt);
ExtMapBuffer2[cnt]=iMAOnArray(ExtMapBuffer4,0,SmoothPeriod,0,SmoothMode,cnt);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments