vivi666 发表于 2005-7-20 07:51

MT4的MACD

这几天才开始用MT4,
MACD只有一根线,请问怎样可以再调出一根线出来?。

楚天 发表于 2005-8-1 14:51

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

//+------------------------------------------------------------------+
//|                                                 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);
}
//+------------------------------------------------------------------+。

haippy 发表于 2005-8-9 10:29

能讲详细些怎么修改吗???? 谢谢。

vivi666 发表于 2005-8-9 23:48

真是电脑高手,多谢,只可惜我不懂。

whirl20000 发表于 2005-8-13 16:09

whirl20000 发表于 2005-8-13 16:09

lyf330 发表于 2006-6-4 05:38

请教:两根先的,好何何搞成一根.
先谢了.

靓女sally 发表于 2006-6-6 22:32

不错~~~

qswu 发表于 2006-7-10 01:40

我知道:huh:

eric0330 发表于 2008-12-4 01:34

:)
页: [1]
查看完整版本: MT4的MACD