//#property strict
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 White
#property indicator_width1 1
#property indicator_minimum -1.5
#property indicator_maximum 1.5

double buff[];
extern int Depth=60;
double price=0.0;
double dir=1;

int init()
{
SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,buff);

IndicatorDigits(Digits+1);
return(0);
}

int start()
{
int i,counted_bars=IndicatorCounted();
if(counted_bars>0) counted_bars--;
i=Bars-counted_bars;
   for (i=Bars;i>=0;i--) {
      if (High[i]==High[iHighest(NULL,0,MODE_HIGH,Depth,i)]) {
         if (dir==1 && High[i]>price) {
            price=High[i];
            buff[i]=1.0;
         }
         else if (dir==-1) {
            dir=1;
            price=High[i];
            buff[i]=1.0;
         }
         else buff[i]=0.0;
      }
      else if (Low[i]==Low[iLowest(NULL,0,MODE_LOW,Depth,i)]) {
         if (dir==-1 && Low[i]<price) {
            price=Low[i];
            buff[i]=-1.0;
         }
         else if (dir==1) {
            dir=-1;
            price=Low[i];
            buff[i]=-1.0;
         }
         else buff[i]=0.0;
      }
      else buff[i]=0.0;
  }

return(0);
}