VolumeAverage_v1

Download script
Author: Copyright � 2007, TrendLaboratory Ltd.
VolumeAverage_v1

This tool is designed to help traders analyze market activity by focusing on trading volume. Instead of just looking at price movements, it helps identify when "significant" action is taking place by comparing current trading volume against a calculated historical average.

How the Logic Works

The script processes three main layers of information to provide a clear picture of market dynamics:

1. Establishing the Baseline (Moving Average) The tool first looks at a specific period of past trading data (which you can customize) to calculate an "Average Volume." This creates a baseline for what a "normal" amount of trading activity looks like for that specific asset and timeframe.

2. Categorizing Market Direction The script tracks the relationship between price changes and volume. It separates the data into two categories based on whether the price is moving up or down:

  • Upward Activity: When the price is increasing, the tool tracks the volume associated with those moves.
  • Downward Activity: When the price is decreasing, the tool tracks the volume associated with those moves.

3. Identifying Breakout Events The core intelligence of this script lies in its "Breakout" detection. It doesn't just show you high volume; it highlights volume that exceeds your specific threshold (the percentage of growth over the average).

  • If the current volume is significantly higher than the calculated average—surpassing the percentage limit you set—the tool flags this as a Breakout.
  • These breakouts are visually distinct, helping you quickly spot moments where a surge of participation might signal a major trend shift or a high-conviction move by large institutional players.

Summary of Visual Output

When you use this indicator, it simplifies the complex data of "volume bars" into actionable visual cues:

  • It provides a continuous line representing the Average Volume for your reference.
  • It populates Histograms that represent standard upward and downward volume.
  • Most importantly, it highlights specific Breakout signals, allowing you to ignore the "noise" of everyday trading and focus on the high-impact moments where volume truly spikes beyond the norm.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
VolumeAverage_v1
//+------------------------------------------------------------------+
//|                                             VolumeAverage_v1.mq4 |
//|                           Copyright © 2007, TrendLaboratory Ltd. |
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |
//|                                   E-mail: igorad2003@yahoo.co.uk |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, TrendLaboratory Ltd."
#property link      "http://finance.groups.yahoo.com/group/TrendLaboratory"

//---- indicator settings
#property  indicator_separate_window
#property indicator_minimum 0
#property indicator_buffers 6
#property indicator_color1  Black
#property indicator_color2  LightBlue
#property indicator_color3  YellowGreen
#property indicator_color4  Orange
#property indicator_color5  Green
#property indicator_color6  Red
#property indicator_width2  1
#property indicator_width3  2
#property indicator_width4  2
#property indicator_width5  2
#property indicator_width6  2

extern int  MA_Length     = 50; // Average Period
extern int  BreakoutPcnt  = 50; // Percent of Breakout
extern int  MA_Mode       =  1; // Mode of Moving Average
//---- indicator buffers
double Volumes[];
double AvgVolumes[];
double UpBuffer[];
double DnBuffer[];
double UpBrk[];
double DnBrk[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping
   SetIndexBuffer(0,Volumes);
   SetIndexBuffer(1,AvgVolumes);       
   SetIndexBuffer(2,UpBuffer);
   SetIndexBuffer(3,DnBuffer);
   SetIndexBuffer(4,UpBrk);
   SetIndexBuffer(5,DnBrk);
//---- drawing settings
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexStyle(3,DRAW_HISTOGRAM);
   SetIndexStyle(4,DRAW_HISTOGRAM);
   SetIndexStyle(5,DRAW_HISTOGRAM);
//---- sets default precision format for indicators visualization
   IndicatorDigits(0);   
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("Volume Average("+MA_Length+","+BreakoutPcnt+","+MA_Mode+")");
   SetIndexLabel(0,"Volumes");      
   SetIndexLabel(1,"AvgVolumes");
   SetIndexLabel(2,NULL);
   SetIndexLabel(3,NULL);
   SetIndexLabel(4,NULL);
   SetIndexLabel(5,NULL);
//---- sets drawing line empty value
   SetIndexEmptyValue(1,0.0);
   SetIndexEmptyValue(2,0.0);       
   SetIndexEmptyValue(3,0.0);
   SetIndexEmptyValue(4,0.0); 
   SetIndexEmptyValue(5,0.0); 
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Volumes                                                          |
//+------------------------------------------------------------------+
int start()
{
   int    i,nLimit,nCountedBars;
//---- bars count that does not changed after last indicator launch.
   nCountedBars=IndicatorCounted();
//---- last counted bar will be recounted
   if(nCountedBars>0) nCountedBars--;
   nLimit=Bars-nCountedBars;
//----
   for(i=0; i<nLimit; i++) Volumes[i] = Volume[i];
   
   for(i=0; i<nLimit; i++)
   {
   AvgVolumes[i] = iMAOnArray(Volumes,0,MA_Length,0,MA_Mode,i);
      
      if(i==Bars-1 || (Close[i] >= Close[i+1]))
      {
      UpBuffer[i] = Volumes[i];
         if(Volumes[i] > AvgVolumes[i]*(1 + BreakoutPcnt*0.01)) 
         {UpBrk[i] = Volumes[i]; UpBuffer[i] = 0;} else UpBrk[i] = 0;
      DnBuffer[i] = 0.0;        
      DnBrk[i] = 0.0;
      }
      else
      if(Close[i] < Close[i+1])
      {
      DnBuffer[i] = Volumes[i];
         if(Volumes[i] > AvgVolumes[i]*(1 + BreakoutPcnt*0.01)) 
         {DnBrk[i] = Volumes[i]; DnBuffer[i] = 0;} else DnBrk[i] = 0;
      UpBuffer[i] = 0.0;        
      UpBrk[i] = 0.0;
      } 
   }        
//---- done
   return(0);
}
//+------------------------------------------------------------------+

Comments