#property copyright "WSAStartup"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 RoyalBlue
#property indicator_width1 2
#property indicator_width2 2 


extern string SETTINGS="===LAGUERRE SETTINGS===";
extern string strLaguerreName="Laguerre-ACS1";
extern double dGamma=0.80;

extern string LEVEL_SETTINGS="===LAGUERRE LEVEL SETTINGS===";
extern double nLevel1        = 0.75;
extern double nLevel2        = 0.45;
extern double nLevel3        = 0.15;

extern string ARROW_SETTINGS="===ARROW SETINGS===";
extern int    nArrowUpCode=233;
extern int    nArrowDownCode=234;
extern int    nArrowDistancePips=5;


double MainBuffer[];
double UpBuffer[];
double DnBuffer[];

int init()
{
  SetIndexBuffer(0,UpBuffer);
  SetIndexStyle(0,DRAW_ARROW); 
  SetIndexArrow(0,nArrowUpCode);
  SetIndexEmptyValue(0, 0.00);
  
  
  SetIndexBuffer(1,DnBuffer);
  SetIndexStyle(1,DRAW_ARROW);
  SetIndexArrow(1,nArrowDownCode);
  SetIndexEmptyValue(1, 0.00);
  
 
  return(0);
}

int start()
{ 
  int limit;
  int counted_bars=IndicatorCounted();

  if(counted_bars<0) return(-1);
  if(counted_bars>0) counted_bars--;
  limit=Bars-counted_bars;
    
  for(int i=0; i<limit; i++)
  { 
     double dLagCur=iCustom(NULL, 0, strLaguerreName,dGamma,1000,2,0,i);
     double dLagPrev=iCustom(NULL, 0, strLaguerreName,dGamma,1000,2,0,i+1);
     
     UpBuffer[i]=EMPTY_VALUE;
     DnBuffer[i]=EMPTY_VALUE;
     if(dLagCur > nLevel1 && dLagPrev < nLevel1) UpBuffer[i] = Low[i]-nArrowDistancePips*Point;
     if(dLagCur < nLevel1 && dLagPrev > nLevel1) DnBuffer[i] = High[i]+nArrowDistancePips*Point;
     if(dLagCur > nLevel3 && dLagPrev < nLevel3) UpBuffer[i] = Low[i]-nArrowDistancePips*Point;
     if(dLagCur < nLevel3 && dLagPrev > nLevel3) DnBuffer[i] = High[i]+nArrowDistancePips*Point;  
  }
   
  return(0);
}


