外汇通|外汇论坛,外汇保证金,交易商,交易平台,网友讨论 外汇通|外汇论坛,外汇保证金,交易商,交易平台,网友讨论 能够反映出MACD棒线的长短变化的指标 - Powered by Discuz!NT Archiver

外汇通论坛

首页 » 软件讨论交流区 » MT4专区 » 能够反映出MACD棒线的长短变化的指标
外汇小鱼儿 - 2008-1-24 15:36:00
//+------------------------------------------------------------------+
//|                                                  BENBEN-MACD.mq4 |
//|                      Copyright ?2005, 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  White
#property  indicator_color3  Red
#property  indicator_color4  Green
//int indicator_color3;
//---- indicator parameters
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
//---- indicator buffers
double    ind_buffer1[];
double    ind_buffer2[];
double    ind_buffer3[];
double    ind_buffer4[];

//+------------------------------------------------------------------+
//| 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();
  double temp,temp1;
 
//---- 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-1; i++)
      {
      temp=1.3*(ind_buffer1-ind_buffer2);
      temp1=1.3*(ind_buffer1[i+1]-ind_buffer2[i+1]);
      if(temp>temp1) {ind_buffer3=temp;ind_buffer4=0;}
      else      {ind_buffer3=0;ind_buffer4=temp;}
     
      }
     
//---- done
  return(0);
  }
外汇小鱼儿 - 2008-1-24 15:37:00
[upload=gif]UploadFile/2008-1/20081241537093103.gif[/upload]


附件: 2425.gif
fys86 - 2008-2-2 18:24:00
谢谢分享
lst98 - 2008-2-6 17:34:00
觉察混乱状态,可以致富
wucunhua - 2008-2-9 17:36:00
编写的‘macdrise.mq4’…   
'=' - left square parenthesis expected for array    C:\Waihui Trader\experts\indicators\macdrise.mq4 (65, 18)
'=' - left square parenthesis expected for array    C:\Waihui Trader\experts\indicators\macdrise.mq4 (68, 18)
'-' - left square parenthesis expected for array    C:\Waihui Trader\experts\indicators\macdrise.mq4 (72, 28)
'=' - assignment expected    C:\Waihui Trader\experts\indicators\macdrise.mq4 (72, 11)
'ind_buffer1' - semicolon expected    C:\Waihui Trader\experts\indicators\macdrise.mq4 (72, 17)
'-' - left square parenthesis expected for array    C:\Waihui Trader\experts\indicators\macdrise.mq4 (72, 28)
'-' - assignment expected    C:\Waihui Trader\experts\indicators\macdrise.mq4 (72, 28)
')' - left square parenthesis expected for array    C:\Waihui Trader\experts\indicators\macdrise.mq4 (72, 40)
')' - assignment expected    C:\Waihui Trader\experts\indicators\macdrise.mq4 (72, 40)
';' - semicolon unexpected    C:\Waihui Trader\experts\indicators\macdrise.mq4 (72, 41)
'=' - left square parenthesis expected for array    C:\Waihui Trader\experts\indicators\macdrise.mq4 (74, 34)
'=' - left square parenthesis expected for array    C:\Waihui Trader\experts\indicators\macdrise.mq4 (74, 51)
'=' - left square parenthesis expected for array    C:\Waihui Trader\experts\indicators\macdrise.mq4 (75, 29)
'=' - left square parenthesis expected for array    C:\Waihui Trader\experts\indicators\macdrise.mq4 (75, 43)
13 错误, 1警告
zsxiong - 2008-9-13 13:46:00
//+------------------------------------------------------------------+
//|                                                  BENBEN-MACD.mq4 |
//|                      Copyright ?2005, 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  White
#property  indicator_color3  Red
#property  indicator_color4  Green
//int indicator_color3;
//---- indicator parameters
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
//---- indicator buffers
double    ind_buffer1[];
double    ind_buffer2[];
double    ind_buffer3[];
double    ind_buffer4[];

//+------------------------------------------------------------------+
//| 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();
  double temp,temp1;
 
//---- 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-1; i++)
      {
      temp=1.3*(ind_buffer1-ind_buffer2);
      temp1=1.3*(ind_buffer1[i+1]-ind_buffer2[i+1]);
      if(temp>temp1) {ind_buffer3=temp;ind_buffer4=0;}
      else      {ind_buffer3=0;ind_buffer4=temp;}
     
      }
     
//---- done
  return(0);
  }
zsxiong - 2008-9-13 14:02:00
这个MACD跟普通的MACD配合一起使用效果会更好:_onion7:
1