//+------------------------------------------------------------------+ //| Custom MACD.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" //---- indicator settings #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Silver #property indicator_color2 Red #property indicator_width1 2 #property indicator_width2 2 //---- indicator parameters extern int WPR_Period=21; extern int MA_Period=14; extern string m = "--Moving Average Types--"; extern string m0 = " 0 = SMA"; extern string m1 = " 1 = EMA"; extern string m2 = " 2 = SMMA"; extern string m3 = " 3 = LWMA"; extern int MA_Type=1; //---- indicator buffers double WPR_Buffer[]; double MA_Buffer[]; int MA_Mode; string strMAType; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE); SetIndexDrawBegin(1,WPR_Period); IndicatorDigits(Digits+1); //---- indicator buffers mapping SetIndexBuffer(0,WPR_Buffer); SetIndexBuffer(1,MA_Buffer); //---- name for DataWindow and indicator subwindow label switch (MA_Type) { case 1: strMAType="EMA"; MA_Mode=MODE_EMA; break; case 2: strMAType="SMMA"; MA_Mode=MODE_SMMA; break; case 3: strMAType="LWMA"; MA_Mode=MODE_LWMA; break; default: strMAType="SMA"; MA_Mode=MODE_SMA; break; } IndicatorShortName( "WPR" + " (" + WPR_Period + ") " + " : " + strMAType+ " (" +MA_Period + ") "); SetIndexLabel(0,"WPR" + " (" +WPR_Period + ") "); SetIndexLabel(1,strMAType+ " (" + MA_Period + ") "); //---- 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; //---- WPR counted in the 1-st buffer for(int i=0; i