Polarized Fractal Efficiency





//+------------------------------------------------------------------+
//|                                    Polarized Fractal Efficiency  |
//|                                                           mladen | 
//| Developed by Hans Hannula                                        |
//| TASC 12:1 "Polarized fractal Efficiency"                         |
//+------------------------------------------------------------------+
#property  copyright "mladen"
#property  link      "mladenfx@gmail.com"

#property  indicator_separate_window
#property  indicator_buffers 2
#property indicator_color1   Red
#property indicator_color2   DarkSlateGray
#property indicator_style2   STYLE_DOT
#property indicator_minimum -105
#property indicator_maximum +105

//
//
//
//
//

extern int PFEPeriod = 9;
extern int Smooth    = 5;

//
//
//
//
//

double buffer1[];
double buffer2[];


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

int init()
{
   IndicatorDigits(0);
   SetIndexBuffer(0,buffer1);
   SetIndexBuffer(1,buffer2); SetIndexLabel(1,NULL);
   IndicatorShortName("Polarized fractal efficiency ("+PFEPeriod+")");
   return(0);
}

//
//
//
//
//

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

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

   for(i = limit; i >= 0; i--)
   {
      buffer1[i] = iPFE(i);
      buffer2[i] = 0;
   }      
   return(0);
}


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

double iPFE(int i)
{
   double pfe = MathSqrt(MathPow(Close[i]-Close[i+PFEPeriod],2)+MathPow(PFEPeriod,2));
   double c2c = 0;
          for (int k=1; k<=PFEPeriod; k++)
                  c2c += MathSqrt(MathPow(Close[i+k-1]-Close[i+k],2)+1);

   //
   //
   //
   //
   //
   
   double fraceff;
   double coeff = 2.0/(1.0+Smooth);
   if (Close[i] > Close[i+PFEPeriod])
          fraceff = MathRound( (pfe/c2c)*100);
   else   fraceff = MathRound(-(pfe/c2c)*100);
   if (i==Bars)
         return(fraceff);
   else  return(buffer1[i+1]+coeff*(fraceff-buffer1[i+1]));
}



Sample





Analysis



Market Information Used:

Series array that contains close prices for each bar


Indicator Curves created:



Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features: