Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
dex_MACDPVT
//+------------------------------------------------------------------+
//| dex_MACDPVT.mq4 |
//| Copyright © 2006, akadex. |
//| tohell |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, akadex"
#property link "tohell"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Red
//---- input parameters
extern int Price =4;
extern int BarsBack =1;
extern int SmoothSlow =26;
extern int SmoothFast =12;
extern int SmoothSignal=9;
//---- buffers
double PVT[],PVTslow[],PVTfast[],PVTtemp[],PVTSignal[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator buffer mapping
IndicatorBuffers(5);
SetIndexBuffer(0,PVT);
SetIndexBuffer(1,PVTSignal);
SetIndexBuffer(2,PVTslow);
SetIndexBuffer(3,PVTfast);
SetIndexBuffer(4,PVTtemp);
//---- indicator line
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
SetIndexStyle(1,DRAW_LINE,STYLE_DOT,1);
//---- name for DataWindow and indicator subwindow label
string short_name="dex_MACDPVT("+SmoothSlow+","+SmoothFast+","+SmoothSignal+")";
IndicatorShortName(short_name);
SetIndexLabel(0,"MACDPVT");
SetIndexLabel(1,"PVTSignal");
SetIndexDrawBegin(0,BarsBack);
SetIndexDrawBegin(1,BarsBack);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Price and Volume Trend |
//+------------------------------------------------------------------+
int start()
{
int i,limit,counted_bars=IndicatorCounted();
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) {PVTtemp[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)
PVTtemp[i] = Volume[i]*(CurPrice-PrevPrice)/PrevPrice + PVTtemp[i+1];
}
}
for(i=limit; i>=0; i--)
{
PVTslow[i]=iMAOnArray(PVTtemp,0,SmoothSlow,0,MODE_EMA,i);
PVTfast[i]=iMAOnArray(PVTtemp,0,SmoothFast,0,MODE_EMA,i);
PVT[i]=PVTfast[i]-PVTslow[i];
}
for(i=limit; i>=0; i--)
PVTSignal[i]=iMAOnArray(PVT,0,SmoothSignal,0,MODE_EMA,i);
//----
return(0);
}
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---