Author: Copyright � 2005, DriverDan
VSI_v1

This tool is designed to provide traders with a more precise understanding of market activity by calculating the volume of trading activity relative to time. While standard volume indicators simply show how much total trading occurred during a specific bar (like a 1-hour or 4-hour candle), this script breaks that data down further to show "Volume Per Second."

How it Works

The core logic of this indicator focuses on uniformity. Because different timeframes have different lengths, standard volume can be misleading when switching between charts. This script solves that by calculating the flow of trading activity based on seconds.

  1. Time-Based Normalization: The script looks at the total volume traded during a specific period and divides it by the actual number of seconds that elapsed in that period. This results in a "speed" of trading, allowing for a consistent comparison of market intensity regardless of which chart timeframe you are viewing.
  2. Real-Time Tracking: For the live candle currently forming on your screen, the script dynamically calculates the volume based on the time passed since the candle began. This ensures that the data stays accurate as the current minute or hour progresses.
  3. Moving Average Integration: To help smooth out the "noise" of rapid fluctuations in trading speed, the tool includes a built-in Moving Average. This allows you to see the overall trend of trading intensity rather than just the erratic second-by-second spikes.

Key Features for Traders

  • Consistency Across Timeframes: By focusing on volume per second, the indicator provides a consistent visual "pulse" of the market. You can compare the intensity of a 15-minute chart against a 4-hour chart more effectively because the underlying math is normalized to the same unit (seconds).
  • Customizable Smoothing: Users can choose the length and type of the Moving Average (such as Simple or Exponential) to suit their specific trading style, helping to identify whether the "trading speed" is accelerating or decelerating.
  • Visual Clarity: The tool outputs two distinct lines on a separate window below your main price chart, clearly separating the raw volume speed from its smoothed trend.

Summary of Best Use

This script is particularly useful for identifying "active" periods in the market. By observing when the volume per second spikes or stays consistently high, traders can gauge the strength of a move and determine whether there is significant participation behind a price change. It is noted to be most effective on intermediate timeframes, such as the 15-minute to 4-hour charts.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
VSI_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

/*
 * Filename:    VSI.mq4
 * Author:      DriverDan
 * Date:        Oct 20, 2005
 *
 * Description: Indicator that calculates volume per second (or period) and the corresponding MA.
 *              Uses volume per second since it will be uniform for all chart periods.
 *              Indicator seems to work best on 15m to 4h charts. IMHO, 1m and 5m periods are
 *              too short for valid results and 1d+ will show low periods for partial days on MT4.
 *
 * Version:     1.0
 *              Initial release
 */

#property copyright         "Copyright © 2005, DriverDan"
#property link              "superfunman2000@yahoo.com"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_buffers 2
#property indicator_color1  DodgerBlue
#property indicator_color2  Red

#define    SECINMIN         60  //Number of seconds in a minute

extern int vsiMAPeriod    = 7;  //Period for the moving average.
extern int vsiMAType      = 1;  //Moving average type. 0 = SMA, 1 = EMA, 2 = SMMA, 3 = LWMA
extern int showPerPeriod  = 0;  //0 = volume per second, 1 = volume per chart period
                                /* Volume per second allows you to compare values for different
                                   chart periods. Otherwise the values it will show will only be
                                   valid for the chart period you are viewing. The graph will
                                   look exactly the same but the values will be different. */

double vsiBuffer[];
double vsiMABuffer[];

/**
 * Initialization function
 */
int init() {
   string vsiTitle = "VSI(" + vsiMAPeriod + ")";
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(0, vsiBuffer);
   SetIndexBuffer(1, vsiMABuffer);
   IndicatorShortName(vsiTitle);
   SetIndexLabel(0, vsiTitle);
   SetIndexLabel(1, "vsiMA(" + vsiMAPeriod + ")");
   SetIndexDrawBegin(1, vsiMAPeriod);
   return(0);
}

/**
 * Main program
 */
int start() {
   int i, limit, timeDiff;
   int counted_bars = IndicatorCounted();
   
   if(counted_bars >= 0) {

      //If counted bars is greater than zero we must subtract 1 so we get in the right position
      if(counted_bars > 0) {
         counted_bars--;
      }

      //Only count bars we haven't already drawn
      limit = Bars - counted_bars;

      for(i = 0; i < limit; i++) {
         //Difference between the current time and the bar start
         timeDiff = CurTime() - Time[i];

         //If we are in the current bar and the tick doesn't fall exactly on the '00:00' min & sec
         if(i == 0 && timeDiff > 0) {
            vsiBuffer[i] = Volume[i] / timeDiff;
         } else {
            //Otherwise calculate the total bar volume divided by the total bar seconds
            vsiBuffer[i] = Volume[i] / (Time[i - 1] - Time[i]);
         }
         
         if(showPerPeriod == 1) {
            vsiBuffer[i] = vsiBuffer[i] * Period() * SECINMIN;
         }
      }

      //Fill the moving average buffer
      for(i = 0; i < limit; i++) {
         vsiMABuffer[i] = iMAOnArray(vsiBuffer, Bars, vsiMAPeriod, 0, vsiMAType, i);
      }
   }

   return(0);
}

Comments