//+--------------------------------------------------------------------------------------------+
//|   Fractal_SR.mq4
//+--------------------------------------------------------------------------------------------+
#property indicator_chart_window
#include <stdlib.mqh>
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Crimson

int i,Trend;
double MyPoint,ev=EMPTY_VALUE;

double Res[];
double Sup[];

int init()
{
   IndicatorBuffers(2);

   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexBuffer(0,Res);
   
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
   SetIndexBuffer(1,Sup);
   
	if (Digits == 5 || (Digits == 3 && StringFind(Symbol(), "JPY") != -1))
	{
      MyPoint = Point*10;
	}
	if (Digits == 6 || (Digits == 4 && StringFind(Symbol(), "JPY") != -1))
	{
      MyPoint = Point*100;
	}

   return(0);
}

int deinit()
{
   return(0);
}

int start()
{
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1); //---- check for possible errors
   if(counted_bars>0) counted_bars--; //---- last counted bar will be recounted
   
   for (i=Bars-counted_bars;i>=0;i--)
   {
      Res[i] = Res[i+1];
      Sup[i] = Sup[i+1];
      
      if (iFractals(NULL,0,MODE_UPPER,i+3) > 0)
      {
         Res[i] = High[i+3];
      }             

      if (iFractals(NULL,0,MODE_LOWER,i+3) > 0)
      {
         Sup[i] = Low[i+3];
      }             
   }
}
//+--------------------------------------------------------------------------------------------+