Exponential Volume Average

Download script
Author: Copyright � 2009, Obaidah.
Exponential Volume Average

This tool is designed to provide traders with a clearer perspective on market activity by smoothing out the raw data of trading volume. In financial markets, volume can often be erratic, with sudden spikes and sharp drops that make it difficult to identify underlying trends at a glance. This script addresses that issue by applying a mathematical "smoothing" technique known as an Exponential Moving Average to the volume data.

How the Logic Works

The core functionality of this tool relies on a specific calculation designed to weigh recent data more heavily than older data. Here is the step-by-step logic:

  • Data Input: The script monitors the trading volume—the total amount of units exchanged during specific timeframes.
  • Weighting Mechanism: Rather than taking a simple average (where every historical data point carries equal weight), the script uses a multiplier based on a user-defined period. This allows the indicator to be more responsive to recent price action while still considering the context of previous volume.
  • Smoothing Process: The logic works backward from the most recent candle toward the oldest data in the history. It calculates a running average where each new value is a blend of the current volume and the previous average.
  • Visual Representation: To make this information easy to digest, the script displays two distinct visual elements:
    1. A Line Chart: This represents the smoothed "average" trend, helping you see the overall flow of volume over time without the "noise" of minor fluctuations.
    2. A Histogram: This provides a comparative look at the actual volume relative to that smoothed average.

Practical Purpose for Traders

By using this logic, the goal is to filter out the "static" of the market. Instead of reacting to every tiny spike in volume, traders can use this tool to identify significant shifts in momentum. When the smoothed line trends upward or shows a distinct change in shape, it suggests a sustained increase in interest from other market participants, potentially signaling the strength behind a move in either direction.

11 Views
0 Downloads
0 Favorites
Exponential Volume Average
//+------------------------------------------------------------------+
//|                                   Exponential Volume Average.mq4 |
//|                                       Copyright © 2009, Obaidah. |
//|                                               clefts@hotmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Obaidah."
#property link      "clefts@hotmail.com"

extern int Period1=12;

int ExtCountedBars=0;
double ExtMapBuffer[];
double Vol[];

#property  indicator_separate_window
#property  indicator_minimum 0
#property  indicator_buffers 2
#property  indicator_color1  White
#property  indicator_color2  White
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(2);
   
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   
   SetIndexDrawBegin(0,Period1);
   SetIndexDrawBegin(1,Period1);
   
   SetIndexBuffer(0,ExtMapBuffer);
   SetIndexBuffer(1,Vol);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   if(Bars<=Period1) return(0);
   ExtCountedBars=IndicatorCounted();
//---- check for possible errors
   if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;
   ema();
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

void ema()
  {
   double pr=2.0/(Period1+1);
   int    pos=Bars-2;
   if(ExtCountedBars>2) pos=Bars-ExtCountedBars-1;
//---- main calculation loop
   while(pos>=0)
     {
      if(pos==Bars-2) ExtMapBuffer[pos+1]=Volume[pos+1];
      ExtMapBuffer[pos]=Volume[pos]*pr+ExtMapBuffer[pos+1]*(1-pr);
 	   pos--;
 	   Vol[pos]=Volume[pos];
     }
  }

Comments