Author: Free
VSA_Candle

This visual tool is designed to provide a simplified view of price action by breaking down the movement of each candle into two primary components: total volatility (the range) and directional momentum (the position of the close).

How it Works

The script analyzes each price candle on your chart and translates that information into a three-part histogram displayed in a separate window. Here is the breakdown of the logic:

1. The Volatility Range (Silver Bars) The tool first calculates the "spread" of every candle, which is the total distance between its highest point and its lowest point.

  • It represents this spread as a symmetrical bar centered at zero.
  • One half extends upward (positive) and the other half extends downward (negative).
  • This allows you to quickly see the total reach or volatility of price movements, regardless of which direction the price actually moved.

2. The Directional Momentum (Red and Green Bars) While the silver bars show the total "stretch" of the candle, the colored bars show where the price actually ended up relative to that stretch. The script identifies a midpoint between the candle's high and low and compares the final closing price to that center point:

  • Green Bars: These appear when the price closes in the upper half of the candle's range. The height of the bar represents how far above the midpoint the price finished.
  • Red Bars: These appear when the price closes in the lower half of the candle's range. The height of the bar represents how far below the midpoint the price finished.

Summary for Traders

By looking at this indicator, you can differentiate between "wide" candles with little conviction (where the silver bar is large but the colored bar is small) and "strong" candles with high conviction (where both the silver and colored bars are significant). It effectively filters out market noise to highlight how aggressively price is moving in a specific direction relative to its total range.

Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
VSA_Candle
//+------------------------------------------------------------------+
//|                                                   VSA_Candel.mq4 |
//+------------------------------------------------------------------+
//| This is a simple code                                            |
//| Everyone wants change, modify or put better fix can do, it's FREE|
//| You see 3 Histogram bar, Silver is the spread of candle high/low |
//| and the middle is at 0.                                          |
//| Red/Green Histogram is the close of candle comparate to the      |
//| middle of the spread.                                            |
//|                                                                  |
//| Defcon                                                                 |
//+------------------------------------------------------------------+
#property copyright "Free"

#property indicator_separate_window
#property indicator_buffers 4

#property indicator_color1 Silver
#property indicator_color2 Silver
#property indicator_color3 Red
#property indicator_color4 Green

#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 2
#property indicator_width4 2

//----
extern color color1 = Silver;
extern color color2 = Silver;
extern color color3 = Red;
extern color color4 = Green;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];

//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM, 0, 3, color1);
   SetIndexBuffer(0, ExtMapBuffer1);
   
   SetIndexStyle(1,DRAW_HISTOGRAM, 0, 3, color2);
   SetIndexBuffer(1, ExtMapBuffer2);
   
   SetIndexStyle(2,DRAW_HISTOGRAM, 0, 2, color3);
   SetIndexBuffer(2, ExtMapBuffer3);
   
   SetIndexStyle(3,DRAW_HISTOGRAM, 0, 2, color4);
   SetIndexBuffer(3, ExtMapBuffer4);
//----
   SetIndexDrawBegin(0,0);
   SetIndexDrawBegin(1,0);
   SetIndexDrawBegin(2,0);
   SetIndexDrawBegin(3,0);
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexBuffer(3,ExtMapBuffer4);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   double haClose,haSpread;
   if(Bars<=10) return(0);
   ExtCountedBars=IndicatorCounted();
//---- check for possible errors
   if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;
   int pos=Bars-ExtCountedBars-1;
   while(pos>=0)
     {
      
      if(Close[pos]<(High[pos]+Low[pos]/2)) 
         {
            
            haClose=Close[pos]-((High[pos]+Low[pos])/2);
            if(haClose<=0){
               ExtMapBuffer3[pos]=haClose;
               ExtMapBuffer4[pos]=0;
            }
            
            if(haClose>=0){
               ExtMapBuffer3[pos]=0;
               ExtMapBuffer4[pos]=haClose;
            }
            
         }
         
      if(Close[pos]>(High[pos]+Low[pos]/2))
         {
            haClose=Close[pos]-((High[pos]+Low[pos])/2);
            ExtMapBuffer3[pos]=0;
            ExtMapBuffer4[pos]=haClose;
         }       
          
      haSpread=(High[pos]-Low[pos]);
      ExtMapBuffer1[pos]=haSpread/2;
      ExtMapBuffer2[pos]=-haSpread/2;
                           
 	      pos--;
    }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments