//+------------------------------------------------------------------+ //| WMACD.mq4 | //| Copyright © 2011 | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011" //---- indicator settings #property indicator_separate_window #property indicator_buffers 6 #property indicator_color1 Black #property indicator_color2 Green #property indicator_color3 Maroon #property indicator_color4 LightSkyBlue #property indicator_color5 DarkKhaki #property indicator_color6 DarkKhaki #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 2 #property indicator_width4 1 #property indicator_width5 1 #property indicator_width6 1 extern int S_MA=26; extern int F_MA=12; extern int SMA=9; extern double Dvn=1.0; extern int Price=0; extern int Mode=1; //---- indicator buffers double MacdBuffer0[]; double MacdBuffer1[]; double MacdBuffer2[]; double SignalBuffer[]; double EnvUpBuffer[]; double EnvDnBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexStyle(0,DRAW_NONE); SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2); SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,2); SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,1); SetIndexStyle(4,DRAW_LINE,STYLE_DOT,1); SetIndexStyle(5,DRAW_LINE,STYLE_DOT,1); SetIndexDrawBegin(0,S_MA); SetIndexDrawBegin(1,S_MA); SetIndexDrawBegin(2,S_MA); SetIndexDrawBegin(3,S_MA); SetIndexDrawBegin(4,S_MA); SetIndexDrawBegin(5,S_MA); SetIndexBuffer(0,MacdBuffer0); SetIndexBuffer(1,MacdBuffer1); SetIndexBuffer(2,MacdBuffer2); SetIndexBuffer(3,SignalBuffer); SetIndexBuffer(4,EnvUpBuffer); SetIndexBuffer(5,EnvDnBuffer); IndicatorDigits(Digits+1); if(Dvn<0.1) Dvn=0.1; if(Dvn>100.0) Dvn=100.0; //---- name for DataWindow and indicator subwindow label IndicatorShortName("WMACD("+S_MA+","+F_MA+","+SMA+")"); SetIndexLabel(1,"MACD"); SetIndexLabel(2,"MACD"); SetIndexLabel(3,"Signal"); SetIndexLabel(4,"EnvUp("+Dvn+")"); SetIndexLabel(5,"EnvDn("+Dvn+")"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Moving Averages Convergence/Divergence | //+------------------------------------------------------------------+ int start() { double prev,current; int counted_bars = IndicatorCounted(); if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; int limit = Bars - counted_bars; if(counted_bars==0) limit-=1+1; //---- macd for(int i=0; i=0; i--) { current=MacdBuffer0[i]; prev=MacdBuffer0[i+1]; if(current>prev) up=true; if(current