MT4里的单线MACD指标转化为双线的MACD的方法

发布网友

我来回答

2个回答

热心网友

  需要修改一下指标参数计算。

  //+------------------------------------------------------------------+
  //| MACD_Billwin.mq4 |
  //| Copyright ?2005, MetaQuotes Software Corp. |
  //| http://www.metaquotes.net |
  //+------------------------------------------------------------------+
  #property copyright "Copyright ?2005, MetaQuotes Software Corp."
  #property link "http://www.metaquotes.net"

  #property indicator_separate_window
  #property indicator_buffers 3
  #property indicator_color1 Aqua
  #property indicator_color2 Red
  #property indicator_color3 Silver
  //---- input parameters
  extern int FastEMA=12;
  extern int SlowEMA=26;
  extern int SignalSMA=9;

  //---- buffers
  double ExtMapBuffer3[];
  //---- indicator buffers
  double ExtSilverBuffer[];
  double ExtRedBuffer[];
  double ExtAquaBuffer[];

  //+------------------------------------------------------------------+
  //| Custom indicator initialization function |
  //+------------------------------------------------------------------+
  int init()
  {
  //---- drawing settings
  SetIndexStyle(0,DRAW_LINE);
  SetIndexStyle(1,DRAW_LINE);
  SetIndexStyle(2,DRAW_HISTOGRAM);
  SetIndexBuffer(2,ExtMapBuffer3);
  //----
  SetIndexDrawBegin(1,SignalSMA);
  IndicatorDigits(5);
  //---- indicator buffers mapping
  SetIndexBuffer(0, ExtSilverBuffer);
  SetIndexBuffer(1, ExtRedBuffer);
  SetIndexBuffer(2, ExtAquaBuffer);
  //---- name for DataWindow and indicator subwindow label
  IndicatorShortName("BillWin_MACD("+FastEMA+","+SlowEMA+","+SignalSMA+")");
  //---- initialization done
  return(0);
  }
  //+------------------------------------------------------------------+
  //| Moving Averages Convergence/Divergence |
  //+------------------------------------------------------------------+
  int start()
  {
  int limit;
  int counted_bars=IndicatorCounted();
  //---- check for possible errors
  if(counted_bars<0) return(-1);
  //---- last counted bar will be recounted
  if(counted_bars>0) counted_bars--;
  limit=Bars-counted_bars;
  //---- macd counted in the 1-st buffer

  for(int i=0; i<limit; i++)
  ExtSilverBuffer=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
  //---- signal line counted in the 2-nd buffer
  for(i=0; i<limit; i++)
  ExtRedBuffer=iMAOnArray(ExtSilverBuffer,Bars,SignalSMA,0,MODE_SMA,i);
  for(i=0; i<limit; i++)
  ExtAquaBuffer=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i) - iMAOnArray(ExtSilverBuffer,Bars,SignalSMA,0,MODE_SMA,i);
  //---- done
  return(0);
  }
  //+------------------------------------------------------------------+。

热心网友

不能直接换的,这个是要做好编程加进去的。

具体做法如下:

1、先编好程序。
2、打开软件下载的文件夹。
3、找到\experts\indicators该文件夹。
4.把编好的程序放到这里,重新打开交易软件就可以找到双线的macd了

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com