【解説】【MQL5 community】 Price and Volume Trend (プライス・ボリューム・トレンド): 価格変動に取引量を織り込んで表示する指標で 「オン・バランス・ボリューム(OBV)」 と特長が似ています。 OBV は以前のロウソク足から直近のロウソク足への価格変動に取引量全てを織り込んで表示するのに対して、PVTは前期の取引量のみを織り込んで表示する。
【計算法】
あるi期について
PVT = ((今期の終値 - 前期の終値) / 前期の終値) × 今期の出来高 + 前期のPVT
【シグナル】
OBV と同様に
1. 価格変化とPVTが同期して上昇・下降していれば、そのトレンドは強い。
2. 価格がPVTに先行して上昇・下降するが、PVTは停滞し始めたときは、価格は引き戻される。
3. PVTが価格に先行して上昇・下降するが、価格は停滞し始めたときは、早晩価格は上昇・下降を継続しPVTに追随する。
//+------------------------------------------------------------------+
//| PVT.mq5 |
//| Copyright 2009, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property description "Price and Volume Trend"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots 1
#property indicator_type1 DRAW_LINE
#property indicator_color1 DodgerBlue
//--- input parametrs
input ENUM_APPLIED_VOLUME InpVolumeType=VOLUME_TICK; // Volumes
//---- indicator buffer
double ExtPVTBuffer[];
//+------------------------------------------------------------------+
//| PVT initialization function |
//+------------------------------------------------------------------+
void OnInit()
{
//--- define indicator buffer
SetIndexBuffer(0,ExtPVTBuffer);
//--- set indicator digits
IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//--- name for DataWindow and indicator label
IndicatorSetString(INDICATOR_SHORTNAME,"PVT");
//--- set index empty value
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
//--- set index draw begin
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,1);
//---- OnInit done
}
//+------------------------------------------------------------------+
//| PVT iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,const int prev_calculated,
const datetime &Time[],
const double &Open[],
const double &High[],
const double &Low[],
const double &Close[],
const long &TickVolume[],
const long &Volume[],
const int &Spread[])
{
//--- variables
int pos;
double Vol;
//--- check for bars count
if(rates_total<2)
return(0);
//--- start calculation
pos=prev_calculated-1;
//--- correct position, when it's first iteration
if(pos<0)
{
pos=1;
ExtPVTBuffer[0]=0.0;
}
//--- main cycle
if(InpVolumeType==VOLUME_TICK)
CalculatePVT(pos,rates_total,Close,TickVolume);
else
CalculatePVT(pos,rates_total,Close,Volume);
//---- OnCalculate done. Return new prev_calculated.
return(rates_total);
}
//+------------------------------------------------------------------+
//| Calculate PVT by volume argument |
//+------------------------------------------------------------------+
void CalculatePVT(int nPosition,
int nRatesCount,
const double &ClBuffer[],
const long &VolBuffer[])
{
if(nPosition<=0) nPosition=1;
//---
for(int i=nPosition;i<nRatesCount;i++)
{
//--- get some data
double PrevClose=ClBuffer[i-1];
//--- calculate PVT value
if(PrevClose!=0)
ExtPVTBuffer[i]=((ClBuffer[i]-PrevClose)/PrevClose)*VolBuffer[i]+ExtPVTBuffer[i-1];
else ExtPVTBuffer[i]=ExtPVTBuffer[i-1];
}
//---
}
//+------------------------------------------------------------------+
【表示結果】
Back to Meta Trader








