//+------------------------------------------------------------------+ //| Custom MACD_AK.mq4 | //| Copyright © 2009, ALEXKUD. | //| http://www.alexkud.com/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2009, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" //---- indicator settings #property indicator_separate_window #property indicator_buffers 6 #property indicator_color1 Silver #property indicator_color2 Green #property indicator_color3 MediumBlue #property indicator_color4 Red #property indicator_color5 Yellow #property indicator_color6 Red //#property indicator_color3 Blue #property indicator_width1 4 #property indicator_width2 4 #property indicator_width3 2 #property indicator_width4 4 #property indicator_width5 2 //---- indicator parameters extern int FastEMA=5; extern int SlowEMA=18; extern int SignalSMA=1; //---- indicator buffers double MacdBuffer[]; double MacdBufferu2[]; double MacdBufferu3[]; double MacdBufferu4[]; double MacdBufferu5[]; double SignalBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(1,MacdBufferu2); SetIndexStyle(2,DRAW_HISTOGRAM); SetIndexBuffer(2,MacdBufferu3); SetIndexStyle(3,DRAW_HISTOGRAM); SetIndexBuffer(3,MacdBufferu4); SetIndexStyle(4,DRAW_HISTOGRAM); SetIndexBuffer(4,MacdBufferu5); SetIndexStyle(5,DRAW_LINE); SetIndexDrawBegin(5,SignalSMA); IndicatorDigits(Digits+1); //---- indicator buffers mapping SetIndexBuffer(0,MacdBuffer); SetIndexBuffer(5,SignalBuffer); //SetIndexStyle(2,DRAW_HISTOGRAM); //SetIndexBuffer(2,MacdBuffer2); //---- name for DataWindow and indicator subwindow label IndicatorShortName("MACD_AK ALEXKUD.COM("+FastEMA+","+SlowEMA+","+SignalSMA+")"); SetIndexLabel(0,"MACD_AK"); SetIndexLabel(5,"Signal"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Moving Averages Convergence/Divergence | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); //---- 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; idelta1 && delta>0) )//|| (delta<0 && delta1>=0) MacdBufferu2[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i); } for(i=0; i=delta1 && delta>0) )//|| ( && delta1>=0))||(delta<=delta1 && delta<0 MacdBufferu3[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i); } for(i=0; i=0) MacdBufferu4[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i); } for(i=0; i=0))||(delta<=delta1 && delta<0 MacdBufferu5[i]=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