Author: Copyright � 2006, TrendLaboratory Ltd.
PVT_v1
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
PVT_v1
//+------------------------------------------------------------------+
//|                                                       PVT_v1.mq4 |
//|                           Copyright © 2006, TrendLaboratory Ltd. |
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |
//|                                       E-mail: igorad2004@list.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, TrendLaboratory Ltd."
#property link      "http://finance.groups.yahoo.com/group/TrendLaboratory"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
//---- input parameters
extern int Price     =0;
extern int BarsBack  =1;
//---- buffers
double PVT[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
//---- indicator buffer mapping
   SetIndexBuffer(0,PVT);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
//---- name for DataWindow and indicator subwindow label
   string short_name="PVT("+Price+","+BarsBack+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"PVT");
   SetIndexDrawBegin(0,BarsBack);
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Price and Volume Trend                                           |
//+------------------------------------------------------------------+
int start()
{
   int   i,limit,counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   if(counted_bars==0) limit=Bars-BarsBack;
   limit=Bars-counted_bars+BarsBack;
//---- 
   for(i=limit; i>=0; i--)
   {
      if(i==Bars-BarsBack) PVT[i]=Volume[i];
      else
      {
      double CurPrice  = iMA(NULL,0,1,0,0,Price,i);
      double PrevPrice = iMA(NULL,0,1,0,0,Price,i+BarsBack);
      
      if(PrevPrice>0)
      PVT[i] = Volume[i]*(CurPrice-PrevPrice)/PrevPrice + PVT[i+1]; 
      }
   }
//----
   return(0);
}

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---