求老师和高手解答!传统MACD指标编译问题... 新评论 [删除] 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); } //+------------------------------------------------------------------+ Ojala EA Can you please help... 编码帮助 okwh 2013.10.29 08:03 #1 ExtMapBuffer2似乎不对,先把它去掉看看。 mt自己带有macd代码,参考 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
请教一下高手,为什么这个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);
}
//+------------------------------------------------------------------+