下载MetaTrader 5
要添加评论,请登录注册
像成功交易者一样进行交易 - 订阅他们的信号
luozhi
5
luozhi 2013.10.27 15:49 

请教一下高手,为什么这个MACD的指标在MT4显示不出来,哪里写错了啊?

#property indicator_separate_window

#property indicator_buffers 3

#property indicator_color1 White

#property indicator_color2 Yellow

#property indicator_color3 Pink

//--- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

double ExtMapBuffer3[];

extern int fastperiod=12;

extern int slowperiod=26;

extern int signal=9;


//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexLabel(0,"DIFF");

SetIndexStyle(1,DRAW_LINE);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexLabel(1,"DEA");

SetIndexStyle(2,DRAW_HISTOGRAM);

SetIndexBuffer(2,ExtMapBuffer3);

SetIndexLabel(2,"MACD");

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

int counted_bars=IndicatorCounted();

int CalculateBars=Bars-counted_bars;

for(int Count=CalculateBars; Count>=0; Count--)

{

ExtMapBuffer1[Count]=(iMA(NULL,0,fastperiod,0,MODE_EMA,MODE_CLOSE,Count)-iMA(NULL,0,slowperiod,0,MODE_EMA,MODE_CLOSE,Count));

ExtMapBuffer2[Count]=iMA(NULL,0,signal,0,MODE_EMA,ExtMapBuffer1[Count],Count);

ExtMapBuffer3[Count]=(ExtMapBuffer1[Count]-ExtMapBuffer2[Count])*2;


}

//----

//----

return(0);

}

//+------------------------------------------------------------------+

效果图

okwh
1629
okwh 2013.10.29 08:03  

ExtMapBuffer2似乎不对,先把它去掉看看。

mt自己带有macd代码,参考

/
要添加评论,请登录注册