【解説】【MQL5 community】 Detrended Price Oscillator (デトレンディッド・プライス・オシレーター): オシレーター系の指標で、 価格の動きからトレンドを除去し、長期的なサイクルを見極めます。 DPOの安値が切り上がっている場合、上昇トレンドが継続する可能性が高く、 DPOの高値が切り下がっている場合、下落トレンドが継続する可能性が高い、 とみなします。つまり逆張り的使い方をします。
【計算法】
DPO = 終値 − 単純移動平均 (CLOSE, (N / 2 + 1))
(既定では、N=12)
【シグナル】
【買いシグナル】
DPOが0以下に下落した後、0以上に反発した時
DPOが「売られ過ぎ水準」以下に下落した後、「売られ過ぎ水準」以上に反発した時
DPOの安値が切り上がっている場合⇒ 上昇トレンド継続
【売りシグナル】
DPOが0以上に上昇した後、0以下に反落した時
DPOが「買われ過ぎ水準」以上に上昇した後、「買われ過ぎ水準」以下に反落した時
DPOの高値が切り下がっている場合 ⇒ 下落トレンド継続
//+------------------------------------------------------------------+
//| DPO.mq5 |
//| Copyright 2009, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property description "Detrended Price Oscillator"
#include <MovingAverages.mqh>
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots 1
#property indicator_type1 DRAW_LINE
#property indicator_color1 DodgerBlue
//--- input parameters
input int InpDetrendPeriod=12; // Period
//--- indicator buffers
double ExtDPOBuffer[];
double ExtMABuffer[];
//--- global variable
int ExtMAPeriod;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit()
{
//--- get length of cycle for smoothing
ExtMAPeriod=InpDetrendPeriod/2+1;
//--- indicator buffers mapping
SetIndexBuffer(0,ExtDPOBuffer,INDICATOR_DATA);
SetIndexBuffer(1,ExtMABuffer,INDICATOR_CALCULATIONS);
//--- set accuracy
IndicatorSetInteger(INDICATOR_DIGITS,_Digits+1);
//--- set first bar from what index will be drawn
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ExtMAPeriod-1);
//--- name for DataWindow and indicator subwindow label
IndicatorSetString(INDICATOR_SHORTNAME,"DPO("+string(InpDetrendPeriod)+")");
//--- initialization done
}
//+------------------------------------------------------------------+
//| Detrended Price Oscillator |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const int begin,
const double &price[])
{
int limit;
int firstInd=begin+ExtMAPeriod-1;
//--- correct draw begin
if(begin>0) PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,firstInd);
//--- preliminary calculations
if(prev_calculated<firstInd)
{
//--- filling
ArrayInitialize(ExtDPOBuffer,0.0);
limit=firstInd;
}
else limit=prev_calculated-1;
//--- calculate simple moving average
SimpleMAOnBuffer(rates_total,prev_calculated,begin,ExtMAPeriod,price,ExtMABuffer);
//--- the main loop of calculations
for(int i=limit;i<rates_total;i++)
ExtDPOBuffer[i]=price[i]-ExtMABuffer[i];
//--- done
return(rates_total);
}
//+------------------------------------------------------------------+
【表示結果】
Back to Meta Trader








