Author: Copyright � 2007, MetaQuotes Software Corp.
PVT

The Price and Volume Trend (PVT) indicator is designed to help traders visualize the relationship between price movements and the trading volume occurring in a specific market. Unlike standard volume indicators that simply show how much trading occurred, this tool attempts to measure "cumulative" momentum by factoring in how much each unit of volume actually contributed to the price change.

How it Works

The core logic of the script relies on tracking the progression of the market over time through three main components:

1. Price Selection The indicator allows you to choose which specific price point should be used for its calculations (such as the Opening, Closing, High, Low, or an average of these figures). By selecting a specific price type, you can fine-tune how "sensitive" the trend line is to different types of market activity.

2. Volume Weighting Instead of looking at volume in isolation, the script looks at the percentage change in price from one period to the next. It then multiplies this percentage change by the volume traded during that period. This helps distinguish between "heavy" trading (large volume) and "meaningful" trading (large volume moving the price significantly).

3. Cumulative Tracking The primary goal of the indicator is to create a continuous trend line. It does this by taking the value from the previous period and adding the newly calculated weighted movement of the current period. This creates a running total—a "cumulative" history—that shows the overall direction of money flow over time.

What this means for the trader

By observing the resulting line on your chart, you are looking at a visual representation of "buying" or "selling" pressure.

  • When the trend line moves upward with significant steepness, it suggests that high volume is being paired with positive price growth.
  • When the line flattens out, it indicates that despite trading activity, the price isn't making significant gains (or losses).

In essence, this script filters out the "noise" of raw volume and provides a smoother view of whether the actual money flowing into the market is driving the price in a specific direction.

Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
PVT
//+------------------------------------------------------------------+
//|                                       Price and Volume Trend.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"
//----
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
//---- input parameters
extern int ExtPVTAppliedPrice = 0;
//---- buffers
double ExtPVTBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string sShortName;
//---- indicator buffer mapping
   SetIndexBuffer(0, ExtPVTBuffer);
//---- indicator line
   SetIndexStyle(0, DRAW_LINE);
//---- sets default precision format for indicators visualization
   IndicatorDigits(0);     
//---- name for DataWindow and indicator subwindow label
   sShortName="PVT";
   IndicatorShortName(sShortName);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| On Balance Volume                                                |
//+------------------------------------------------------------------+
int start()
  {
   int    i, nLimit, nCountedBars;
   double dCurrentPrice, dPreviousPrice;
//---- 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 - 1;
//---- 
   for(i = nLimit; i >= 0; i--)
     {
       if(i == Bars - 1)
           ExtPVTBuffer[i] = Volume[i];
       else
         {
           dCurrentPrice = GetAppliedPrice(ExtPVTAppliedPrice, i);
           dPreviousPrice = GetAppliedPrice(ExtPVTAppliedPrice, i + 1);
           ExtPVTBuffer[i] = ExtPVTBuffer[i+1] + Volume[i]*(dCurrentPrice - 
                             dPreviousPrice) / dPreviousPrice;  
         }
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetAppliedPrice(int nAppliedPrice, int nIndex)
  {
   double dPrice;
//----
   switch(nAppliedPrice)
     {
      case 0:  dPrice=Close[nIndex];                                        break;
      case 1:  dPrice=Open[nIndex];                                         break;
      case 2:  dPrice=High[nIndex];                                         break;
      case 3:  dPrice=Low[nIndex];                                          break;
      case 4:  dPrice=(High[nIndex] + Low[nIndex]) / 2.0;                   break;
      case 5:  dPrice=(High[nIndex] + Low[nIndex] + Close[nIndex]) / 3.0;   break;
      case 6:  dPrice=(High[nIndex] + Low[nIndex] + 2*Close[nIndex]) / 4.0; break;
      default: dPrice = 0.0;
     }
//----
   return(dPrice);
  }
//+------------------------------------------------------------------+

Comments