//+------------------------------------------------------------------+
//|                                        Moving Average Spread.mq4 |
//|                                              lucidlamp@gmail.com |
//+------------------------------------------------------------------+

#property link "lucidlamp@gmail.com"

#property indicator_separate_window

#property indicator_buffers 1
#property indicator_color1 Blue
#property indicator_level1 0

extern int Depth=200;

double ExtMapBuffer1[];

int init()
	{
		IndicatorBuffers(1);
		IndicatorShortName("Moving Average Spread (" + Depth + ")");
		SetIndexBuffer(0,ExtMapBuffer1);
		SetIndexStyle(0,DRAW_LINE);
		SetIndexLabel(0,"Signal");
		SetIndexDrawBegin(0,Depth);
		SetIndexShift(0,0);
	}

int deinit()
	{
	}

int start()
	{
		
		int iIndicatorCounted=IndicatorCounted();
		if(iIndicatorCounted<0)
			{
				return(-1);
			}
		int iLimit=(Bars-Depth)-iIndicatorCounted;
		for(int i=iLimit;i>=0;i--)
			{
				double dTemp=iMA(NULL,0,Depth,0,MODE_SMA,PRICE_CLOSE,i);
				ExtMapBuffer1[i]=((Close[i]-dTemp)/dTemp)*100;
			}
	}

