//------------------------------------------------------------------
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1  Lime
#property indicator_color2  Red

//
//
//
//
//

//extern int Length = 8;
//extern int Price  = PRICE_CLOSE;

//
//
//
//
//

double bartu[];
double bartd[];
double trend[];
double vel[];

//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
//

int init()
{
   IndicatorBuffers(4);
      SetIndexBuffer(0,bartu); SetIndexStyle(0,DRAW_HISTOGRAM);
      SetIndexBuffer(1,bartd); SetIndexStyle(1,DRAW_HISTOGRAM);
      SetIndexBuffer(2,vel);
      SetIndexBuffer(3,trend);
   return(0);
}
int deinit() { return(0); }

//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
//

int start()
{
   int counted_bars=IndicatorCounted();
      if(counted_bars<0) return(-1);
      if(counted_bars>0) counted_bars--;
         int limit = MathMin(Bars-counted_bars,Bars-1);

   //
   //
   //
   //
   //
   
   for(int i=limit; i>=0; i--)
   {
      //vel[i] = iVelocity(iMA(NULL,0,1,0,MODE_SMA,Price,i),Length,i);
      vel[i] = iMA(NULL,0,30,0,MODE_SMMA,0,i);
         bartu[i] = EMPTY_VALUE;
         bartd[i] = EMPTY_VALUE;
            if (iClose(NULL,0,i )> vel[i]) trend[i] =  1;
            if (iClose(NULL,0,i) < vel[i]) trend[i] = -1;
               if (trend[i]== 1) { bartu[i] = High[i]; bartd[i] = Low[i]; }
               if (trend[i]==-1) { bartd[i] = High[i]; bartu[i] = Low[i]; }
   }
   return(0);
}

//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//
//
//
//
//

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//
