//+------------------------------------------------------------------+ //| GMACD.mq4 | //| Copyright 2012, Guriev Invest | //| http://www.gurievinvest.org.ua | //+------------------------------------------------------------------+ #property copyright "Copyright 2012, Guriev Invest" #property link "http://www.gurievinvest.org.ua" #property indicator_separate_window #property indicator_buffers 4 #property indicator_color1 Blue #property indicator_color2 Red #property indicator_color3 Red #property indicator_color4 Green #property indicator_style2 STYLE_DOT #property indicator_width3 3 #property indicator_width4 3 //=====Параметры индикатора===== extern int FastMA = 12; extern int SlowMA = 26; extern int SignalMA = 9; //=====Буферы индикатора===== double MacdBufferRed[]; double MacdBufferGreen[]; double SignalBuffer[]; double LineBuffer[]; //+------------------------------------------------------------------+ //| Инициализация | //+------------------------------------------------------------------+ int init() { SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE); SetIndexStyle(2,DRAW_HISTOGRAM); SetIndexStyle(3,DRAW_HISTOGRAM); SetIndexDrawBegin(0,SlowMA); SetIndexDrawBegin(1,SlowMA+SignalMA); SetIndexDrawBegin(2,SlowMA+SignalMA); SetIndexDrawBegin(3,SlowMA+SignalMA); IndicatorDigits(Digits+1); SetIndexBuffer(0,LineBuffer); SetIndexBuffer(1,SignalBuffer); SetIndexBuffer(2,MacdBufferRed); SetIndexBuffer(3,MacdBufferGreen); IndicatorShortName("MACD("+FastMA+","+SlowMA+","+SignalMA+")"); SetIndexLabel(0,"Line"); SetIndexLabel(1,"Signal"); SetIndexLabel(2,"MACD"); SetIndexLabel(3,"MACD"); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit; double volFirst = 0; double volSecond = 0; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; if(counted_bars==0) limit-=1+1; //=====Подсчет первой средней for(int i=0; ivolSecond) MacdBufferRed[i]=volFirst; else MacdBufferGreen[i]=volFirst; } return(0); } //+------------------------------------------------------------------+