Author:
VSA_v2

This script functions as a sophisticated visual indicator designed to help traders interpret market sentiment by analyzing the relationship between three key trading components: Volume, Moving Averages (Trends), and ATR (Volatility).

Instead of providing a single line on your chart, it creates four distinct histograms in a separate window. These histograms represent specific "market conditions" or "moods," allowing you to see how different types of market activity are distributed over time.

How the Logic Works

The script examines every price bar and classifies it into one of several categories based on specific rules. It looks at whether volume is increasing or decreasing, which direction the trend is moving (using two different Moving Averages), and whether the market's volatility is expanding or contracting.

The final four visual bars are calculated as follows:

  • Bullish Momentum (Trend Strength): This measures "Aggressive Buying." It captures instances where volume is rising, the trend is moving upward, and volatility is increasing. By subtracting the corresponding bearish conditions, it shows a net score of how strongly the market is pushing higher with high conviction.
  • Consolidation/Stability: This identifies periods where there is significant activity but the "velocity" of price movement is slowing down. It highlights moments where volume remains high but volatility is shrinking, suggesting a potential cooling off or a period of heavy accumulation/distribution.
  • Bearish Momentum (Trend Strength): This focuses on "Aggressive Selling." It captures instances where volume is rising, the trend is moving downward, and volatility is increasing. The histogram reflects the net pressure of sellers dominating the market with high-impact moves.
  • Exhaustion or Reversal Signals: This tracks periods of "Weakened Activity." It looks for instances where volume is dropping while price trends or volatility remain steady. These bars represent a lack of conviction in the current move, often signaling that the current trend might be losing steam.

Summary for the Trader

Essentially, this script acts as a Market Sentiment Decoder. Rather than just telling you "the price went up," it visualizes the quality of that move:

  1. Is the move fueled by high-conviction volume and rising volatility?
  2. Is the move losing steam despite the price direction?
  3. Is the market currently finding a stable equilibrium?

By watching these four histograms, you can better distinguish between a healthy, strong trend and a "tired" move that may be about to reverse.

Price Data Components
Series array that contains tick volumes of each bar
Indicators Used
Indicator of the average true rangeMoving average indicator
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
VSA_v2
//+------------------------------------------------------------------+
//|                                     VSA        mich99@o2.pl      |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
//----
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 YellowGreen
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Gray


#property indicator_level1 0

extern int TimeFrame = 0;

extern string        o="2 x MA trend";

extern int MA_per = 1;
extern int MA2_per = 1;
extern int MA_mode = 1;
extern int MA2_mode = 1;
extern int MA_price = 3;

extern int MA2_price = 2;


//---- buffers
double P1;
double P2;
double K1;
double K2;
double S1;
double S2;
double D1;
double D2;

double P1Buffer[];
double P2Buffer[];
double P3Buffer[];
double P4Buffer[];



//----
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexBuffer(0, P1Buffer);
   SetIndexBuffer(1, P2Buffer);
   SetIndexBuffer(2, P3Buffer);
   SetIndexBuffer(3, P4Buffer);
  
//----
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 6);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 4);
   SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, 2);
   
   SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID, 1);
   
   IndicatorShortName("VSA_v2("+TimeFrame+","+MA_per+")");
//----
   IndicatorDigits(1);
   
   Comment(" Are You identifying Yourself with Your mind? ");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   Comment("");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

   int i,ii;
   static int pii=-1;
   
   for(i = 0; i <3000 ; i++)//iBars(Symbol(),TimeFrame)
     {
       ii = iBarShift(Symbol(), Period(), iTime(Symbol(),TimeFrame,i), true);
       //----
       if (pii!=ii)
       {
         P1=0;
         P2=0;
         K1=0;
         K2=0;        
         S1=0;
         S2=0;
         D1=0;
         D2=0;
         
         
         P1Buffer[ii]=0;
         P2Buffer[ii]=0;
         P3Buffer[ii]=0;
         P4Buffer[ii]=0;
         
       }
       
       if (ii != -1)
       {
         if (iVolume(Symbol(),TimeFrame,i)>iVolume(Symbol(),TimeFrame,i+1) && iMA(NULL,TimeFrame,MA2_per,0,MA2_mode,MA2_price,i)>iMA(NULL,TimeFrame,MA_per,0,MA_mode,MA_price,i) &&  iATR(Symbol(),TimeFrame, 1, i)>iATR(Symbol(),TimeFrame, 1, i+1) )
         {
           P1 = P1+iVolume(Symbol(),TimeFrame,i);//MathAbs(iClose(Symbol(),TimeFrame,i)-iClose(Symbol(),TimeFrame,i+1));
         }
                
         if (iVolume(Symbol(),TimeFrame,i)>iVolume(Symbol(),TimeFrame,i+1) &&  iMA(NULL,TimeFrame,MA2_per,0,MA2_mode,MA2_price,i)<iMA(NULL,TimeFrame,MA_per,0,MA_mode,MA_price,i) &&  iATR(Symbol(),TimeFrame, 1, i)>iATR(Symbol(),TimeFrame, 1, i+1) )
         {
           P2 = P2+iVolume(Symbol(),TimeFrame,i);//MathAbs(iClose(Symbol(),TimeFrame,i)-iClose(Symbol(),TimeFrame,i+1));High[Highest(NULL,TimeFrame,MODE_HIGH,MA_per,i)]
         }
         
         
         
         
         
           if (iVolume(Symbol(),TimeFrame,i)>iVolume(Symbol(),TimeFrame,i+1)  && iMA(NULL,TimeFrame,MA2_per,0,MA2_mode,MA2_price,i)>iMA(NULL,TimeFrame,MA_per,0,MA_mode,MA_price,i) &&  iATR(Symbol(),TimeFrame, 1, i)<iATR(Symbol(),TimeFrame, 1, i+1)  )
         {
           K1 = K1+iVolume(Symbol(),TimeFrame,i);//MathAbs(iClose(Symbol(),TimeFrame,i)-iClose(Symbol(),TimeFrame,i+1));
         }
         
        if (iVolume(Symbol(),TimeFrame,i)>iVolume(Symbol(),TimeFrame,i+1)  && iMA(NULL,TimeFrame,MA2_per,0,MA2_mode,MA2_price,i)<iMA(NULL,TimeFrame,MA_per,0,MA_mode,MA_price,i) &&  iATR(Symbol(),TimeFrame, 1, i)<iATR(Symbol(),TimeFrame, 1, i+1)  )
         {
           K2 = K2+iVolume(Symbol(),TimeFrame,i);//MathAbs(iClose(Symbol(),TimeFrame,i)-iClose(Symbol(),TimeFrame,i+1));
         }
           
           
           
           
           
            if (iVolume(Symbol(),TimeFrame,i)<iVolume(Symbol(),TimeFrame,i+1)  && iMA(NULL,TimeFrame,MA2_per,0,MA2_mode,MA2_price,i)>iMA(NULL,TimeFrame,MA_per,0,MA_mode,MA_price,i) &&  iATR(Symbol(),TimeFrame, 1, i)>iATR(Symbol(),TimeFrame, 1, i+1)  )
         {
           S1 = S1+iVolume(Symbol(),TimeFrame,i);//MathAbs(iClose(Symbol(),TimeFrame,i)-iClose(Symbol(),TimeFrame,i+1));
         }
         
        if (iVolume(Symbol(),TimeFrame,i)<iVolume(Symbol(),TimeFrame,i+1)  && iMA(NULL,TimeFrame,MA2_per,0,MA2_mode,MA2_price,i)<iMA(NULL,TimeFrame,MA_per,0,MA_mode,MA_price,i) &&  iATR(Symbol(),TimeFrame, 1, i)>iATR(Symbol(),TimeFrame, 1, i+1)  )
         {
           S2 = S2+iVolume(Symbol(),TimeFrame,i);//MathAbs(iClose(Symbol(),TimeFrame,i)-iClose(Symbol(),TimeFrame,i+1));
         }
        
        
        
        
        
            if (iVolume(Symbol(),TimeFrame,i)<iVolume(Symbol(),TimeFrame,i+1)  && iMA(NULL,TimeFrame,MA2_per,0,MA2_mode,MA2_price,i)>iMA(NULL,TimeFrame,MA_per,0,MA_mode,MA_price,i) &&  iATR(Symbol(),TimeFrame, 1, i)<iATR(Symbol(),TimeFrame, 1, i+1)  )
         {
           D1 = D1+iVolume(Symbol(),TimeFrame,i);//MathAbs(iClose(Symbol(),TimeFrame,i)-iClose(Symbol(),TimeFrame,i+1));
         }
         
        if (iVolume(Symbol(),TimeFrame,i)<iVolume(Symbol(),TimeFrame,i+1)  && iMA(NULL,TimeFrame,MA2_per,0,MA2_mode,MA2_price,i)<iMA(NULL,TimeFrame,MA_per,0,MA_mode,MA_price,i) &&  iATR(Symbol(),TimeFrame, 1, i)<iATR(Symbol(),TimeFrame, 1, i+1)  )
         {
           D2 = D2+iVolume(Symbol(),TimeFrame,i);//MathAbs(iClose(Symbol(),TimeFrame,i)-iClose(Symbol(),TimeFrame,i+1));
         }
        
        
         
         if (iVolume(Symbol(),TimeFrame,i)==iVolume(Symbol(),TimeFrame,i+1)   &&  iATR(Symbol(),TimeFrame, 2, i)==iATR(Symbol(),TimeFrame, 2, i+1) )
         {
           P1 = 0;//P1+(iVolume(Symbol(),TimeFrame,i)/2);
           P2 = 0;//P2-(iVolume(Symbol(),TimeFrame,i)/2);
         }
       }
       P1Buffer[ii]=P1-P2;
       P2Buffer[ii]=K1-K2;
       P3Buffer[ii]=S1-S2;
       P4Buffer[ii]=(D1-D2);
       
       pii=ii;
    }
//----
   return(0);
  }

Comments