EA编译时没有错误,但运行时在专家栏中提示: cannot load indicator 'MACD' [4002],不知是什么原因。源代码如下,请高手给看一下:

 
//Macd
double Macd(string symbol,ENUM_TIMEFRAMES period,int fast,int slow,int index)
  {
   double buf[];
   ArraySetAsSeries(buf,true);
   int a=iMACD(symbol,period,0,fast,slow,STO_CLOSECLOSE);
   int copied=CopyBuffer(a,0,0,index+1,buf); 
   return(buf[index]);
  }
 
没有使用iCustom或者使用出错
 

 int a=iMACD(symbol,period,0,fast,slow,STO_CLOSECLOSE); 

這個要放在Init宣告比較不會出錯

 
这意思是这个macd是个指标,要放到指标文件夹,放到ea文件夹加载就会提示这个
 
iMacd放OnInit()里面,然后OnTick()或者其他地方调用,就不会出错