[MT4指标]MomFilter指标
附图指标,
mt4指标类型:趋势指标
是否能用在mt4手机版上:否
是否含有未来函数:无
///+------------------------------------------------------------------
//| MomFilter_v1.mq4
//| Copyright ? 2006, Forex-TSD.com
//| Written by IgorAD,[email protected]
//| http://finance.groups.yahoo.com/group/TrendLaboratory
//+------------------------------------------------------------------
#property copyright "Copyright ? 2006, Forex-TSD.com "
#property link "http://www.forex-tsd.com/"
#property indicator_separate_window
#property indicator_minimum -0.05
#property indicator_maximum 1.00
#property indicator_buffers 2
#property indicator_color1 DeepSkyBlue
#property indicator_color2 Red
//---- input parameters
extern int PeriodMOM=14;
//---- indicator buffers
double UpBuffer;
double DnBuffer;
//+------------------------------------------------------------------
//| Custom indicator initialization function
//+------------------------------------------------------------------
int init()
{
string short_name;
//---- indicator line
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,4);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,4);
SetIndexBuffer(0,UpBuffer);
SetIndexBuffer(1,DnBuffer);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
short_name="MOM Filter("+PeriodMOM+") (Down trade only when down bars are orange)";
IndicatorShortName(short_name);
SetIndexLabel(0,"UpTrend");
SetIndexLabel(1,"DownTrend");
//----
SetIndexDrawBegin(0,PeriodMOM);
SetIndexDrawBegin(1,PeriodMOM);
//----
return(0);
}
//+------------------------------------------------------------------
//| MOMFilter_v1
//+------------------------------------------------------------------
int start()
{
int shift,trend;
double MOM0;
for(shift=Bars-PeriodMOM-1;shift>=0;shift--)
{
MOM0=iMomentum(NULL,0,PeriodMOM,PRICE_CLOSE,shift);
if (MOM0>100) trend=1;
if (MOM0<100) trend=-1;
if (trend>0)
{
if (MOM0 > 100) UpBuffer[shift]=1.0;
else UpBuffer[shift] = EMPTY_VALUE;
DnBuffer[shift]=0;
}
if (trend<0)
{
if (MOM0 < 100) DnBuffer[shift]=-1.0;
else DnBuffer[shift] = EMPTY_VALUE;
UpBuffer[shift]=0;
}
}
return(0);
}
//+------------------------------------------------------------------+
Flat%20Trend%20MOM.jpg

发表于:2017-08-09 23:51只看该作者
2楼
韬客交易社区-国内最大的外汇交易社区
韬客社区www.talkfx.co