外汇论坛 外兔财经

开启左侧

请大家注意。并请高手回答,

[复制链接]
发表于 2005-9-8 13:21 | 显示全部楼层 |阅读模式
https://www.y2cn.com
大家注意到了没有,许多看盘器上的MACD 指标(同一时间周期)不一样,特别是柱状图差距很大,有的甚至还是相反的。这将影响买卖的时间点。MT4 的就和 FutureTrader及招行 的彼此不一样,不仅图形的方向不一样,而且图形也不一样。这样MACD指标就很难给出正确的买卖时间了。我本想自己从编辑一下MT的macd 指标,可没看明白,所以想求高手给解释一下。
 楼主| 发表于 2005-9-8 13:33 | 显示全部楼层
特说明参数是一样的,都是,12。26。9
 楼主| 发表于 2005-9-8 17:06 | 显示全部楼层
两个算法不一样的,我研究了一下。
有这样的算法:
DIFF : EMA(CLOSE,SHORT) - EMA(CLOSE,LONG);
DEA  : EMA(DIFF,M,1);
MACD : 2*(DIFF-DEA), COLORSTICK


MT4 是这样的:
DIFF : EMA(CLOSE,SHORT) - EMA(CLOSE,LONG);
DEA  SMA(DIFF,M);
MACD : 2*(DIFF-DEA), COLORSTICK

图形是有一定差距的。
发表于 2005-9-9 22:10 | 显示全部楼层
//+------------------------------------------------------------------+
//|                                                  Custom MACD.mq4 |
//|                      Copyright ?2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright ?2004, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 4
#property  indicator_color1  Blue
#property  indicator_color2  Yellow
#property  indicator_color3  Red
#property  indicator_color4  Green
//int indicator_color3;
//---- indicator parameters
extern int FastEMA=5;
extern int SlowEMA=34;
extern int SignalSMA=5;
//---- indicator buffers
double     ind_buffer1[];
double     ind_buffer2[];
double     ind_buffer3[];
double     ind_buffer4[];
double     temp;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,1);
   SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,1);
   SetIndexDrawBegin(1,SignalSMA);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
//---- indicator buffers mapping
   if(!SetIndexBuffer(0,ind_buffer1) && !SetIndexBuffer(1,ind_buffer2)&& !SetIndexBuffer(2,ind_buffer3)&& !SetIndexBuffer(3,ind_buffer4))
      Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("MACD("+FastEMA+","+SlowEMA+","+SignalSMA+")");
   SetIndexLabel(0,"MACD");
   SetIndexLabel(1,"Signal");
//---- 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++)
      ind_buffer1=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++)
      ind_buffer2=iMAOnArray(ind_buffer1,Bars,SignalSMA,0,MODE_SMA,i);
      
   for(i=0; i<limit; i++)
      {
       temp=1.3*(ind_buffer1-ind_buffer2);
       if(temp>0) {ind_buffer3=temp;ind_buffer4=0;}
       else       {ind_buffer3=0;ind_buffer4=temp;}
      
      }
      
//---- done
   return(0);
  }


MT中调试通过

本版积分规则

QQ|手机版 Mobile Version|Archiver|关于我们 About Us|联系我们 Contact Us|Y2外汇论坛 外兔财经

GMT+8, 2024-9-29 05:25 , Processed in 0.051282 second(s), 23 queries .

Powered by Discuz! X7.2

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表