Navigation´╝ÜHome > Content >

Laguerre_rsi_variation_(2).mq4

Time: 2017-03-22 | Download file:Laguerre_rsi_variation_(2).mq4

//+------------------------------------------------------------------+
//|                                                  LaguerreRSI.mq4 |
//|                                                                  |
//| a variation on the LAguerre RSI theme                            |
//| solves some problems with low lag smoothing                      |
//+------------------------------------------------------------------+

#property copyright "mladen"
#property link      "[email protected]"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1  clrOrange
#property indicator_width1  3

//
//
//
//
//

extern double LaguerreGamma = 0.9;
extern int    LaguerrePrice = 0; 
extern int    RSIDataLevel  = 0;
extern int    RSIPeriod     = 8;
extern bool   Smooth        = true;

//
//
//
//
//

double RSI[];
double L0[];
double L1[];
double L2[];
double L3[];
double LR[];

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int init()
{
   IndicatorBuffers(6);
	SetIndexBuffer(0, RSI); SetIndexLabel(0,"Laguerre RSI");
   SetIndexBuffer(1, L0);
   SetIndexBuffer(2, L1);
   SetIndexBuffer(3, L2);
   SetIndexBuffer(4, L3);
   SetIndexBuffer(5, LR);
         RSIDataLevel = MathMax(MathMin(RSIDataLevel,2),0);
   IndicatorShortName(" ");
   return(0);
}
int deinit() { return(0); }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//

int start()
{
   int counted_bars=IndicatorCounted();
   int i,limit;

   if (counted_bars<0) return(-1);
   if (counted_bars>0) counted_bars--;
          limit = MathMin(Bars-counted_bars,Bars-1);

   //
   //
   //
   //
   //
   
   for (i=limit; i>=0; i--)
   {
		double Price=iMA(NULL,0,1,0,MODE_SMA,LaguerrePrice,i);
		
		L0[i] = (1.0 - LaguerreGamma)*Price + LaguerreGamma*L0[i+1];
		L1[i] = -LaguerreGamma*L0[i] + L0[i+1] + LaguerreGamma*L1[i+1];
		L2[i] = -LaguerreGamma*L1[i] + L1[i+1] + LaguerreGamma*L2[i+1];
		L3[i] = -LaguerreGamma*L2[i] + L2[i+1] + LaguerreGamma*L3[i+1];

      //
      //
      //
      //
      //
      		
         double cu = 0;
         double cd = 0;
         for (int k=0; k 0) cu += diff;
               if (diff < 0) cd -= diff;
            }

         //
         //
         //
         //
         //
         
         if ((cu+cd)!=0)
               LR[i] = 0.5*((cu-cd)/(cu+cd)+1);
         else  LR[i] = 0;
         if (Smooth)
               RSI[i] = (LR[i] + 2.0*LR[i+1] + LR[i+2])/4.0;
         else  RSI[i] = LR[i];               
	}
   
   //
   //
   //
   //
   //
   
   return(0);
}

Recommend