【解説】 【MQL5 community】 Momentum (モメンタム): モメンタムとは、株価などの動きに使う言葉で勢い・方向性という意味。 相場の勢い(強弱)、反転の目安となる水準を見ることが出来る指標です。
【計算法】
(1)モメンタム(%)=(当日の価格/N期間前の価格)×100、Nは期間。
次の時折使われます。Meta Trader は(1)のみ。
(2)モメンタム=当日の価格 − N期間前の価格、Nは期間。
【シグナル】
(1)の場合は、100%を基準として、(2)の場合は、0を基準として、
モメンタムが100% or 0 以上の時は強気相場と判断、
モメンタムが100% or 0 以下の時は弱気相場と判断。
逆行現象と呼ばれる相場が上昇(下降)しているのにモメンタムはその逆で下降(上昇)している状態があります。 モメンタムには相場に先行して動くという特徴があり、相場がピーク(ボトム)をつける前にモメンタムがピーク(ボトム)をつけ、それがトレンドの反転・終息のシグナルとなります。
100% or 0 ラインから極端に離れた地点(買われすぎ/売られすぎ)での売買は、 前回モメンタムが反転した水準を参考にするという方法があります。
//+------------------------------------------------------------------+
//| Momentum.mq5 |
//| Copyright 2009, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots 1
#property indicator_type1 DRAW_LINE
#property indicator_color1 DodgerBlue
//---- input parameters
input int InpMomentumPeriod=14; // Period
//---- indicator buffers
double ExtMomentumBuffer[];
//--- global variable
int ExtMomentumPeriod;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit()
{
//--- check for input value
if(InpMomentumPeriod<0)
{
ExtMomentumPeriod=14;
Print("Input parameter InpMomentumPeriod has wrong value. Indicator will use value ",ExtMomentumPeriod);
}
else ExtMomentumPeriod=InpMomentumPeriod;
//---- buffers
SetIndexBuffer(0,ExtMomentumBuffer,INDICATOR_DATA);
//---- name for DataWindow and indicator subwindow label
IndicatorSetString(INDICATOR_SHORTNAME,"Momentum"+"("+string(ExtMomentumPeriod)+")");
//--- sets first bar from what index will be drawn
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ExtMomentumPeriod-1);
//--- sets drawing line empty value
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
//--- digits
IndicatorSetInteger(INDICATOR_DIGITS,2);
}
//+------------------------------------------------------------------+
//| Momentum |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const int begin,
const double &price[])
{
//--- start calculation
int StartCalcPosition=(ExtMomentumPeriod-1)+begin;
//---- insufficient data
if(rates_total<StartCalcPosition)
return(0);
//--- correct draw begin
if(begin>0) PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,StartCalcPosition+(ExtMomentumPeriod-1));
//--- start working, detect position
int pos=prev_calculated-1;
if(pos<StartCalcPosition)
pos=begin+ExtMomentumPeriod;
//--- main cycle
for(int i=pos;i<rates_total;i++)
{
ExtMomentumBuffer[i]=price[i]*100/price[i-ExtMomentumPeriod];
}
//--- OnCalculate done. Return new prev_calculated.
return(rates_total);
}
//+------------------------------------------------------------------+
【表示結果】
トレンドを表示。レンジ相場で有効であるため、加熱すると、冷ます方向へ。
Back to Meta Trader







