Polarized Fractal Efficiency
Download scriptThe Polarized Fractal Efficiency indicator is a sophisticated technical analysis tool designed to measure the "quality" or "intensity" of price movement over a specific period. Instead of simply showing where the price is going, it evaluates how efficiently the market is moving from point A to point B, filtering out minor noise to highlight significant trends.
How the Logic Works
The core functionality of this script can be broken down into three main stages:
1. Measuring Total Displacement The indicator first looks back at a set timeframe (defined by the "PFEPeriod"). It calculates the direct distance between the current price and the price from that previous period. This establishes the "goal" or the total move that occurred during that window.
2. Evaluating Path Efficiency Simultaneously, the script analyzes every individual step taken between those two points. Rather than looking at the start and end alone, it calculates the sum of all the small movements in between. By comparing the direct distance to the actual path traveled, the tool can determine how "efficient" the move was.
- If the price moved in a straight, forceful line, the efficiency score is high.
- If the price moved in many erratic zags and corrections to get to the same destination, the efficiency score is lower.
3. Polarity and Smoothing The tool then applies two final layers of refinement:
- Polarity: The indicator assigns a positive or negative value based on whether the price ended higher or lower than it started. This allows traders to see both the direction and the strength of the trend simultaneously.
- Smoothing: To prevent the data from looking jagged or "jumpy" on the chart, the script uses a mathematical smoothing coefficient. This stabilizes the line, making it easier for the human eye to identify sustained trends rather than momentary price spikes.
Summary for Traders
In plain terms, this indicator tells you how much "effort" the market is exerting to move in a certain direction. It identifies high-conviction trends where the price is moving smoothly and purposefully, while helping to filter out periods of indecision where the price might be fluctuating significantly without making real progress.
//+------------------------------------------------------------------+
//| 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]));
}
Comments