//+------------------------------------------------------------------+ //| MACD Elder Impulse Max.mq4 | //| MaxAgeNT | //| http:/forex.agent.zp.ua/ | //+------------------------------------------------------------------+ // MACD, раскрашенный по Импульсной системе Элдера // #property copyright "Copyright © 2012, MaxAgeNT" #property link "http://forex.agent.zp.ua/" //---- indicator settings #property indicator_separate_window #property indicator_buffers 6 #property indicator_color1 Green #property indicator_color2 MediumBlue #property indicator_color3 Red #property indicator_color4 SeaGreen #property indicator_color5 Yellow #property indicator_color6 Chocolate // Ivory #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 2 #property indicator_width4 1 #property indicator_width5 2 #property indicator_width6 1 //---- indicator parameters extern int FastEMA_Period=13; // Период пользовательской FastEMA extern int FastMA_Period=12; // FastMA MACD extern int SlowMA_Period=26; // SlowMA MACD extern int SignalMA_Period=9; // SignalMA MACD int FastMA_Shift=0; int FastMA_Method=1; int FastMA_Price=0; int FastMA_Timeframe=0; int SlowMA_Shift=0; int SlowMA_Method=1; int SlowMA_Price=0; int SlowMA_Timeframe=0; int SignalMA_Shift=0; int SignalMA_Method=0; //---- indicator buffers double ind_buffer1[]; double ind_buffer2[]; double ExtBuffer1[]; double ExtBuffer2[]; double ExtBuffer3[]; double ExtBuffer4[]; int Shift; int MA_Period; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { if(FastMA_Price>6 || FastMA_Price<0) FastMA_Price=0; if(FastMA_Method>3 || FastMA_Method<0) FastMA_Method=1; if(FastMA_Period<=0) FastMA_Period=12; if(SlowMA_Price>6 || SlowMA_Price<0) SlowMA_Price=0; if(SlowMA_Method>3 || SlowMA_Method<0) SlowMA_Method=1; if(SlowMA_Period<=0) SlowMA_Period=26; if(SignalMA_Method>3 || SignalMA_Method<0) SignalMA_Method=0; if(SignalMA_Period<=0) SignalMA_Period=9; if(FastMA_Shift<0) FastMA_Shift=0; if(SlowMA_Shift<0) SlowMA_Shift=0; if(FastMA_Shift>=SlowMA_Shift) { Shift=FastMA_Shift; } else { Shift=SlowMA_Shift; } if(FastMA_Period>=SlowMA_Period) { FastMA_Period=12; SlowMA_Period=26; } if(SignalMA_Period>=SlowMA_Period) { MA_Period=SignalMA_Period; } else { MA_Period=SlowMA_Period; } //---- drawing settings SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexDrawBegin(0,MA_Period+Shift+4*SignalMA_Period); SetIndexBuffer(0,ExtBuffer1); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexDrawBegin(1,MA_Period+Shift+4*SignalMA_Period); SetIndexBuffer(1,ExtBuffer2); SetIndexStyle(2,DRAW_HISTOGRAM); SetIndexDrawBegin(2,MA_Period+Shift+4*SignalMA_Period); SetIndexBuffer(2,ExtBuffer3); SetIndexStyle(3,DRAW_HISTOGRAM); SetIndexDrawBegin(3,MA_Period+Shift+4*SignalMA_Period); SetIndexBuffer(3,ExtBuffer4); SetIndexStyle(4,DRAW_NONE); SetIndexDrawBegin(4,MA_Period+Shift+4*SignalMA_Period); SetIndexBuffer(4,ind_buffer1); SetIndexStyle(5,DRAW_LINE); SetIndexDrawBegin(5,MA_Period+Shift+4*SignalMA_Period); SetIndexBuffer(5,ind_buffer2); SetIndexShift(5,SignalMA_Shift); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1); //---- name for DataWindow and indicator subwindow label IndicatorShortName("maxMACDcolor ("+FastEMA_Period+","+FastMA_Period+","+SlowMA_Period+","+SignalMA_Period+")"); SetIndexLabel(0,NULL); SetIndexLabel(1,NULL); SetIndexLabel(2,NULL); SetIndexLabel(3,NULL); SetIndexLabel(4,"maxMACDcolor"); SetIndexLabel(5,"Signal"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Moving Averages Convergence/Divergence | //+------------------------------------------------------------------+ int start() { double prev,current,Sprev,Scurrent; 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; for(int i=0; iprev) && (Scurrent>Sprev)) { ExtBuffer1[i]=current; // Green ExtBuffer2[i]=0.0; ExtBuffer3[i]=0.0; ExtBuffer4[i]=0.0; } else if(( currentprev) && (ScurrentSprev)) { ExtBuffer1[i]=0.0; ExtBuffer2[i]=current; // MediumBlue ExtBuffer3[i]=0.0; ExtBuffer4[i]=0.0; } } return(0); } //+------------------------------------------------------------------+