Polarized_Fractal_Efficiency





//+------------------------------------------------------------------+
//|                                 Polarized_Fractal_Efficiency.mq4 |
//|                                                     Yuriy Tokman |
//|                                            yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman"
#property link      "yuriytokman@gmail.com"

#property indicator_separate_window

#property indicator_buffers 3
#property indicator_color1 Lime
#property indicator_color2 Teal

#property indicator_level1 100
#property indicator_level2 75
#property indicator_level3 50
#property indicator_level4 25
#property indicator_level5 -25
#property indicator_level6 -50
#property indicator_level7 -75
#property indicator_level8 -100

extern string __íàñòðîéêè_íèäèêàòîðà__ = "Çäåñü èçìåíÿåì";
extern int Perriod = 9;
extern int period_MA = 5;//0-3

double FractalEfficiency[];
double Line_Zero[];
double FractalEfficiencyTmp[];
 

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE,EMPTY,3);
   SetIndexBuffer(0,FractalEfficiency);
   
   SetIndexStyle(1,DRAW_LINE,1,1);
   SetIndexBuffer(1,Line_Zero);
   
   SetIndexStyle(2,DRAW_NONE);
   SetIndexBuffer(2,FractalEfficiencyTmp);      
   
   IndicatorShortName("Polarized_Fractal_Efficiency ("+Perriod+")");
   
   SetIndexLabel(0," ISQ#481971287  ");
   SetIndexLabel(1," yuriytokman@gmail.com  ");      
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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=limit; i>=0; i--)
   {
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
     //Path1 = Sqrt( (Close – Close[Period])^2 + Period^2 )
     //Path2 = Sum(from i=0 to Period-1)Sqrt( (Close[i] – Close[i-1])^2 + 1 )
     //FractalEfficiencyTmp = Sign(Close – Close[Period]) * Path1 / Path2 * 100.0
     //FractalEfficiency = ExpMovAvg(FractalEfficiencyTmp, Smoothing Period),
     //where:
     //Close[Period] (or Close[i]) is Close Period (or i) bars back,
     //Sign(a) is +1 if a>0 and –1 if a<0,
     //Sqrt(a) is square root of a,
     //Sum is a summation operation,
     //ExpMovAvg is Exponential Moving Average over Smoothing Period bars.
     //Path1 is simply the hypotenuse of the big triangle formed by the current 
     //Close and Period bars ago Close. Path2 is the sum of hypotenuses of small 
     //triangles formed by each Close point.
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$  
    double Path1, Path2 = 0, a;
    Path1 = MathSqrt(MathPow(Close[i] - Close[i+Perriod],2)+MathPow(Perriod,2)); 
    for (int k=1; k<=Perriod; k++)
    Path2 += MathSqrt(MathPow(Close[i+k-1]-Close[i+k],2)+1);
     
    a = Close[i] - Close[i+Perriod];
    if (a>0) FractalEfficiencyTmp[i] = +1*Path1 / Path2 * 100.0;
    else     FractalEfficiencyTmp[i] = -1*Path1 / Path2 * 100.0;   
    }
    
    for(i=limit; i>=0; i--)
    {
     FractalEfficiency[i] = iMAOnArray(FractalEfficiencyTmp,0,period_MA,0,2,i);
     Line_Zero[i]=0;
    }
//----
   return(0);
  }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:

Series array that contains close prices for each bar


Indicator Curves created:

Implements a curve of type DRAW_LINE

Implements a curve of type DRAW_NONE

Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: