Navigation´╝ÜHome > Content >

Adaptive_Laguerre_Filter_+_ma_crosses.mq4

Time: 2010-04-03 | Download file:Adaptive_Laguerre_Filter_+_ma_crosses.mq4

//------------------------------------------------------------------
//
//------------------------------------------------------------------
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 LimeGreen
#property indicator_color2 Orange

extern int  LagLookBack     = 20;
extern int  LagMedian       = 5;
extern int  LagPrice        = PRICE_MEDIAN;
extern int  MaPeriod        = 89;
extern int  MaMethod        = MODE_LWMA;
extern int  MaPrice         = PRICE_CLOSE;
extern bool alertsOn        = false;
extern bool alertsOnCurrent = false;
extern bool alertsMessage   = true;
extern bool alertsSound     = false;
extern bool alertsEmail     = false;

double filter[];
double diff[];
double ma[];
double cross[];
double sortDiff[];

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//

int init() 
{
   IndicatorBuffers(4);
   SetIndexBuffer(0,filter);
   SetIndexBuffer(1,ma);
   SetIndexBuffer(2,diff);
   SetIndexBuffer(3,cross);
      ArrayResize(sortDiff,LagMedian);
   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--)   
   {
      double price   = iMA(NULL,0,1,0,MODE_SMA,LagPrice,i);
             diff[i] = MathAbs(price - filter[i+1]);
      double hi    = diff[ArrayMaximum(diff,LagLookBack,i)];
      double lo    = diff[ArrayMinimum(diff,LagLookBack,i)];
      double alpha = 0;
         if (hi!=lo)    
         {
            for (int j=0; jma[i]) cross[i] =  1;
         if (filter[i]        

Recommend