百变霹雳小小招财猫!
大型投行
- 金钱
- 36815 美元
- 权重
- 437 股
|
MOM_MACD.mq4
(5.09 KB, 下载次数: 81)
代码:
- //+------------------------------------------------------------------+
- //| Custom Secret_Key_Code_MACD.mq4 |
- //| Copyright ?2013, Behzad.H |
- //| https://login.mql5.com/en/users/behzad.h |
- //+------------------------------------------------------------------+
- #property copyright "Copyright ?2013, Behzad Habibzadeh Khoei"
- #property link "behzadhabibzade@gmail.com"
- //---- indicator settings
- #property indicator_separate_window
- #property indicator_buffers 6
- #property indicator_color1 Black //macd
- #property indicator_color2 Red //Signal
- #property indicator_color3 Lime //Macd Up
- #property indicator_color4 Red //Macd Dn
- #property indicator_color5 Black //Shadow
- #property indicator_color6 Black //Shadow
- #property indicator_width1 1
- #property indicator_width2 2
- //---- indicator parameters
- extern int FastLen=12;
- extern int SlowLen=26;
- extern int Length=9;
- extern double StDv=1.0;
- int loopbegin;
- int shift;
- double zeroline;
- //---- indicator buffers
- //---- buffers
- double ExtMapBuffer1[]; // Macd
- double ExtMapBuffer2[]; // Macd
- double ExtMapBuffer3[]; // Macd
- double ExtMapBuffer4[]; // Macd
- double bbMacd[];
- double bbMacdline;
- double Upperband[];
- double Lowerband[];
- double avg[];
- double sDev;
- double mean;
- double sumSqr;
- //+------------------------------------------------------------------+
- //| Custom indicator initialization function |
- //+------------------------------------------------------------------+
- int init()
- {
- //---- 6 additional buffers are used for counting.
- IndicatorBuffers(8);
- //---- drawing settings
- SetIndexBuffer(0,bbMacd);
-
- SetIndexBuffer(1,avg);
- SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
- SetIndexArrow(1,166);
- IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
- SetIndexBuffer(2,ExtMapBuffer1);//Macd line
- SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID,0);
- SetIndexArrow(2,108);
- IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
-
-
- SetIndexBuffer(3,ExtMapBuffer2);//Macd line
- SetIndexStyle(3,DRAW_ARROW,STYLE_SOLID,0);
- SetIndexArrow(3,108);
- IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
- SetIndexBuffer(4,ExtMapBuffer3);//Macd line
- SetIndexStyle(4,DRAW_ARROW,STYLE_SOLID,0);
- SetIndexArrow(4,166);
- IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
-
-
- SetIndexBuffer(5,ExtMapBuffer4);//Macd line
- SetIndexStyle(5,DRAW_ARROW,STYLE_SOLID,0);
- SetIndexArrow(5,166);
- IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
-
-
-
- SetIndexBuffer(6,Lowerband);
- SetIndexBuffer(7,Upperband);
-
-
- //---- name for DataWindow and indicator subwindow label
- IndicatorShortName("Momentum MACD ("+FastLen+","+SlowLen+","+Length+")");
- SetIndexLabel(0,"Macd");
- SetIndexLabel(1,"Signal Line");
- SetIndexLabel(2,"Macd Up&Dn");
-
- //---- initialization done
- return(0);
- }
- //+------------------------------------------------------------------+
- //| Custor indicator deinitialization function |
- //+------------------------------------------------------------------+
- int deinit()
- {
- //---- TODO: add your code here
- // --------------------------
- //----
- 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;
- //loopbegin = Bars-1;
- //for(int i = loopbegin; i >= 0; i--)
- for(int i=0; i<limit; i++)
- bbMacd[i]=iMA(NULL,0,FastLen,0,MODE_EMA,PRICE_CLOSE,i) - iMA(NULL,0,SlowLen,0,MODE_EMA,PRICE_CLOSE,i);
- for(i=0; i<limit; i++)
- {
- avg[i]=iMAOnArray(bbMacd,0,Length,0,MODE_SMA,i);
-
- //Comment("avg[i]=",avg[i]," bbMacd[i+1]=",bbMacd[i+1]," bbMacd[i]=",bbMacd[i]," Length=",Length," sDev=",sDev," Upperband=",Upperband[i]," Lowerband=",Lowerband[i]);
-
-
-
- sDev = iStdDevOnArray(bbMacd,0,Length,MODE_EMA,0,i);
-
-
- Upperband[i] = avg[i] + (StDv * sDev);
- Lowerband[i] = avg[i] - (StDv * sDev);
-
-
- ExtMapBuffer1[i]=bbMacd[i];
- ExtMapBuffer2[i]=bbMacd[i];
- ExtMapBuffer3[i]=bbMacd[i];
- ExtMapBuffer4[i]=bbMacd[i];
-
- if (bbMacd[i]>bbMacd[i+1])
- {
- ExtMapBuffer2[i]=EMPTY_VALUE; ExtMapBuffer4[i]=EMPTY_VALUE;
- }
-
- if (bbMacd[i]<bbMacd[i+1])
- {
- ExtMapBuffer1[i]=EMPTY_VALUE; ExtMapBuffer3[i]=EMPTY_VALUE;
- }
-
-
- }
-
-
- //---- done
- return(0);
-
- }
- //+------------------------------------------------------------------+
-
复制代码 |
|