//+------------------------------------------------------------------+
//|                                                    sparky777.mq4 |
//|                                            	 lucidlamp@gmail.com |
//+------------------------------------------------------------------+

#property link "lucidlamp@gmail.com"

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 Blue
#property indicator_width1 1
#property indicator_style1 STYLE_SOLID

#property indicator_color2 Yellow
#property indicator_width2 1
#property indicator_style2 STYLE_SOLID

extern double DampFactor=0.3;
extern int MALength=5;

double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];

int init()
	{
		IndicatorBuffers(3);
		IndicatorShortName("sparky777");
		IndicatorDigits(Digits);
		
		SetIndexBuffer(0,ExtMapBuffer1);
		SetIndexStyle(0,DRAW_LINE);
		SetIndexLabel(0,"Projected MA");
		SetIndexDrawBegin(0,MALength);
		
		SetIndexBuffer(1,ExtMapBuffer2);
		SetIndexStyle(1,DRAW_LINE);
		SetIndexLabel(1,StringConcatenate(MALength," Period MA"));
		SetIndexDrawBegin(1,MALength);

		SetIndexBuffer(2,ExtMapBuffer3);
	}
   
int deinit()
	{
	}
   
int start()
	{
		int iIndicatorCounted=IndicatorCounted();
		if(iIndicatorCounted<0)
			{
				return(-1);
			}
		int iLimit=Bars-iIndicatorCounted;
		for(int i=iLimit;i>=0;i--)
			{
				double Mid=(High[i]+Low[i])/2;
				ExtMapBuffer3[i]=Mid-(DampFactor*(Mid-ExtMapBuffer3[i+1]));
				ExtMapBuffer1[i]=ExtMapBuffer3[i];
				ExtMapBuffer2[i]=iMA(NULL,0,MALength,0,MODE_SMA,PRICE_CLOSE,i);
			}
	}