Positive volume index (PVI) & Negative Volume Index (NVI) Indicators

 

Hi, does somebody have the mq4 files for PVI (Positive Volume Index) & NVI (Negative Volume Index) indicators? Please send me a link from where I can download this files or PM.

 

Hi someone have the code for NVI and PVI ????

thanks

 
pres120:

Hi someone have the code for NVI and PVI ????

thanks


There can be no such thing in MT4 as there is no "trading volume ". "Volume" in MT4 refers to tick count . . .
 
pres120:

Hi someone have the code for NVI and PVI ????

thanks

I do believe what you are asking for is less code, and more of a subscription service, because volume data would have to be derived from a delivery service from a (multiple) brokers. Generally speaking, this type of data can be very expensive.

Good luck

 

//+------------------------------------------------------------------+
//|                                                          PVI.mq4 |
//|                                          Alexander Kocian, 2013  |     
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 3

#property indicator_color2 Yellow
#property indicator_style2 DRAW_LINE
#property indicator_color3 White

extern int MA_Period=2; // PVI smoothing
extern int ME_Period=10;  // EMA for comparison

double PVI[];
double SmoothedPVI[];
double EMA[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   string shortName="PVI("+MA_Period+")  EMA("+ME_Period+")";
   IndicatorShortName(shortName);

   IndicatorDigits(Digits);
   SetIndexStyle(0,DRAW_NONE);
   SetIndexBuffer(0,PVI);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,SmoothedPVI);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,EMA);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int pos;
 
   if (Bars<MA_Period) return(-1);
   int limit=Bars-2;

   double Vol0,Vol1;

//if(ExtCountedBars>2) limit=Bars-ExtCountedBars-1;
  
   PVI[0]=1.0;

   for(pos=1;pos<limit;pos++)
     {
      Vol0=Volume[pos-1];
      Vol1=Volume[pos];

      if(Vol0>Vol1)
         PVI[pos]=PVI[pos-1]*(1+((Close[pos]-Close[pos-1])/Close[pos-1]));
      else
         PVI[pos]=PVI[pos-1];
     
     }

//simple MA
   int limit_s=limit-MA_Period;
   double first_value=0.0;
   for(int i=0;i<MA_Period;i++)
      first_value+=PVI[limit_s+i];
   SmoothedPVI[limit_s]=first_value/MA_Period;

   pos=limit_s-1;
   while(pos>=0)
     {
      SmoothedPVI[pos]=SmoothedPVI[pos+1]+(PVI[pos]-PVI[pos+MA_Period])/MA_Period;
      pos--;
     }
//EMA10 for comparison
   int limit_e=limit-ME_Period;
   double SmoothFactor=2.0/(1.0+ME_Period);

   if(limit_e>=0) EMA[limit_e]=PVI[limit_e];
   pos=limit_e-1;
   while(pos>=0)
     {
      EMA[pos]=SmoothFactor*PVI[pos+1]+(1-SmoothFactor)*EMA[pos+1];
      pos--;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

MetaQuotes Software Corp.
MetaQuotes Software Corp.
  • www.metaquotes.net
Millions of traders and hundreds of brokers cannot be wrong — they have chosen MetaTrader 5 for trading Forex and financial markets! Learn more
Reason: