[MT4指标]iAnchMom趋势指标
附图指标,iAnchMom趋势指标
mt4指标类型:趋势指标
是否能用在mt4手机版上:否
是否含有未来函数:无
主要使用34 120的两根ema指标来做趋势的判断
//+------------------------------------------------------------------+
//| iAnchMom.mq4 |
//| |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Teal
//---- input parameters
extern int EMA_period=34;
extern int MomPeriod=120;
//---- buffers
double MomBuffer;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(1);
SetIndexBuffer(0, MomBuffer);
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2,Teal);
SetIndexDrawBegin(0,MomPeriod + MomPeriod + 1);
//---- name for DataWindow and indicator subwindow label
short_name="iAnchMom("+MomPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| AnchMom |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
double a,b;
int SMA_Period = MomPeriod + MomPeriod + 1;
if(Bars<=SMA_Period) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=SMA_Period;i++) MomBuffer[Bars-i]=0.0;
//----
i=Bars-SMA_Period-1;
if(counted_bars>=SMA_Period) i=Bars-counted_bars-1;
while(i>=0)
{
a = iMA(NULL,0,EMA_period,0, MODE_EMA,PRICE_CLOSE, i);
b = iMA(NULL,0,SMA_Period,0, MODE_SMA, PRICE_CLOSE, i);
MomBuffer= 100*((a / b)-1);
i--;
}
return(0);
}
//+------------------------------------------------------------------+iAnchMom.jpg
发表于:2017-08-11 09:45只看该作者
2楼
阅尽天下指标
发表于:2017-09-17 10:49只看该作者
3楼
谢谢分享!