Author: Copyright � 2009, yijomza@gmail.com.
VSA_Text

This script is designed to analyze market activity by identifying specific patterns in price movement and trading volume. It functions as a Volume Spread Analysis (VSA) tool, which helps traders interpret the "story" behind the price action by looking at how much effort was made to move the market in a certain direction.

How the Logic Works

The script scans through historical price data to evaluate three primary components of every candle:

  1. Spread Analysis: It calculates the range (the distance between the high and low) of each price bar. By comparing a current bar's range to the average range of the previous 20 bars, it determines if the market is experiencing a "Wide Spread" (high volatility/activity) or a "Narrow Spread" (low volatility/consolidation).
  2. Volume Analysis: It looks at the trading volume of each bar relative to the average volume over the previous 20 bars. This allows the script to distinguish between high-interest moves and low-interest movements.
  3. Closing Price Position: It identifies where the price closed in relation to its high and low for that period—specifically whether it closed at the top, the bottom, or in the middle of the range.

Identified Market Conditions

By combining these three components (Spread, Volume, and Closing Position), the script categorizes specific candles into distinct market behaviors. When a new pattern is detected, the script places a text label on your chart to alert you to the following conditions:

  • Upthrust: Indicates heavy selling pressure where price moves up significantly but fails to hold, often suggesting a reversal or "fake-out" at the top.
  • No Demand Bar: Suggests that buyers are not interested in pushing the price higher despite current movements.
  • Stopping Volume: Identifies a move supported by high volume that may be hitting a significant wall of resistance or support.
  • Reverse Upthrust: A sign of significant buying interest following a period of downward movement.
  • No Supply Bar: Indicates a lack of selling pressure, suggesting that sellers are exhausted.
  • Effort To Move Up/Down: These labels highlight instances where high volume and wide spreads are actively pushing the price in a specific direction, signaling strong momentum.

Visual Output

Instead of just providing raw numbers, this script automatically cleans the chart and places clearly visible text labels (in orange by default) at the exact point where these significant market behaviors occur. This allows you to see the "intent" of large market participants directly on your price graph.

9 Views
0 Downloads
0 Favorites
VSA_Text
//+------------------------------------------------------------------+
//|                                                      VSA_YJZ.mq4 |
//|                              Copyright © 2009, yijomza@gmail.com |
//|                                                yijomza@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, yijomza@gmail.com."
#property link      "yijomza@gmail.com"

#property indicator_chart_window
//----Input
extern int SpreadPeriod=20
          ,VolumePeriod=20;
extern color TextColor=Orange;

//---- buffers

int o;int c=0;
string updnbar,spreadtype,volumetype,closebar,VSAType,newVSA;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   ObjectsDeleteAll(0,OBJ_TEXT); 
   
   
   for(c=1000;c>=0;c--)
   {
   //--------
      if(Close[c+1]>Close[c+2])
      {
       updnbar="UP BAR";
      }
      if(Close[c+1]<Close[c+2])
      {
       updnbar="DOWN BAR";
      }
   //--------  
       if(Close[c+1]<=(((High[c+1]-Low[c+1])*0.3)+Low[c+1]))
       {
        closebar="DOWN CLOSE";
       }
       else if(Close[c+1]>=(High[c+1]-((High[c+1]-Low[c+1])*0.3)))
       {
        closebar="UP CLOSE";
       }
       else
       {
        closebar="MID CLOSE";
       }
   //--------
      if(sp(c)=="WIDE SPREAD BAR"
      && vt(c)=="HIGH VOLUME" 
      && closebar=="DOWN CLOSE" 
      && Close[c+2]>Close[c+3]
      && High[c+1]>High[c+2]
      )
      {
       VSAType="UPTHRUST";
      }
      else
      if(sp(c)=="NARROW SPREAD BAR" 
      && (vt(c)=="LOW VOLUME" || Volume[c+1]<Volume[c+2]) 
      && (closebar=="DOWN CLOSE" || closebar=="MID CLOSE") 
      && updnbar=="UP BAR"
      )
      {
       VSAType="No Demand Bar";
      }
      else
      if((vt(c)=="HIGH VOLUME") 
      && (closebar=="UP CLOSE") 
      && updnbar=="DOWN BAR"
      )
      {
       VSAType="Stopping Volume";
      }
      else
      if(sp(c)=="WIDE SPREAD BAR" 
      && vt(c)=="HIGH VOLUME" 
      && closebar=="UP CLOSE" 
      && updnbar=="UP BAR"
      && Low[c+1]<Low[c+2]
      )
      {
       VSAType="Reverse UPTHRUST";
      }
      else
      if(sp(c)=="NARROW SPREAD BAR" 
      && vt(c)=="LOW VOLUME" 
      && closebar=="DOWN CLOSE" 
      && updnbar=="DOWN BAR"
      )
      {
       VSAType="NO Supply Bar";
      }
      else
      if(sp(c)=="WIDE SPREAD BAR"
      && updnbar=="UP BAR"
      && closebar=="UP CLOSE"
      && (vt(c)=="HIGH VOLUME" || Volume[c+1]>Volume[c+2])
      )
      {
       VSAType="Effort To Move Up";
      }   
      else
      if(sp(c)=="WIDE SPREAD BAR"
      && updnbar=="DOWN BAR"
      && closebar=="DOWN CLOSE"
      && (vt(c)=="HIGH VOLUME" || Volume[c+1]>Volume[c+2])
      )
      {
       VSAType="Effort To Move Down";
      }   
      else VSAType="No Comment";
   //--------
      if(newVSA!=VSAType)
      {
         o++;  
         double mid=(High[c+1]+Low[c+1])/2;
         if(VSAType!="No Comment")
         {
            Text("t"+o,VSAType,Time[c+1],mid,TextColor);
         }
       newVSA=VSAType;  
      }
   }   
//----
   return(0);
  }
//+------------------------------------------------------------------+
void Text(string name,string txt,int time,double price,color cl)
{
ObjectCreate(name,OBJ_TEXT,0,time,price);
ObjectSetText(name,txt,8,"Comic Sans MS",cl);
ObjectSet(name, OBJPROP_ANGLE,90);
}
//--------
string sp(int s)
{
      int spread,avgspread,cnt,collectspread;
      for(int i=SpreadPeriod;i>=1;i--)
      {
       spread=(High[s+i]-Low[s+i])/Point;
       collectspread+=spread;
      }
      avgspread=collectspread/(SpreadPeriod-1);
      double curspread=(High[s+1]-Low[s+1])/Point;
      double HMtimespread=curspread/avgspread;
   
      if(HMtimespread>=1.8)
      {
       spreadtype="WIDE SPREAD BAR";
      }
      else if(HMtimespread<=0.8)
      {
       spreadtype="NARROW SPREAD BAR";
      }
      else spreadtype="";
return(spreadtype);
}
//--------
string vt(int s)
{
      double vol,collectvol,avgvol;
      for(int i=VolumePeriod;i>=1;i--)
      {
       vol=Volume[s+i];
       collectvol+=vol;
      }
      avgvol=collectvol/(VolumePeriod-1);
   
      if(Volume[s+1]>=avgvol)
      {
       volumetype="HIGH VOLUME";
      }
      else volumetype="LOW VOLUME";
return(volumetype);
}

Comments