Author: Copyright � 2008, Gimapiero Raschetti
PFE

This technical indicator is designed to measure and visualize market momentum by evaluating the relationship between price movement and market volatility. Instead of simply looking at how much a price has moved, this tool attempts to determine the "strength" or "efficiency" of that movement relative to the amount of activity occurring in the market.

Core Logic Breakdown

1. Movement vs. Volatility Analysis The script operates by looking at a specific window of time (defined by the Period setting). Within this window, it performs two primary calculations simultaneously:

  • Price Displacement: It identifies the difference between the starting price and the ending price over the chosen period.
  • Market "Noise": It calculates the total cumulative movement (the sum of all price changes) that occurred throughout that same period.

2. The Efficiency Ratio By dividing the total price displacement by the cumulative market noise, the indicator produces a value that represents how "clean" or "efficient" the price move was.

  • A high value suggests that the price moved significantly in one direction with relatively little erratic movement (high momentum).
  • A low value suggests that while the price moved, it did so with a lot of "choppiness" or back-and-forth activity (low efficiency/high noise).

3. Smoothing and Filtering To make the data easier to interpret for the user, the script includes an optional smoothing layer. If enabled, the raw momentum values are passed through an Exponential Moving Average (EMA). This filters out minor fluctuations and highlights the broader trend of the momentum, making it easier to identify sustained shifts in market behavior rather than temporary spikes.

Visual Representation

The result is plotted in a separate window at the bottom of the trading platform. It provides a visual gauge of whether the current price action is moving with purpose and strength or if it is simply drifting amidst high volatility without clear direction.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
PFE
//+------------------------------------------------------------------+
//|                                                          PFE.mq4 |
//|                             ©2008, giampiero.raschetti@gmail.com |
//|                                            http://www.fxtrade.it |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Gimapiero Raschetti"
#property link      "http://www.fxtrade.it/"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue

//#property indicator_minimum -1
//#property indicator_maximum 1
#property indicator_level1 0

//---- input parameters
extern int PfePeriod=5;
extern bool UseAvarage=true;
extern int MaPeriod=5;

//---- buffers
double Pfe[];
double PfeBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
   IndicatorBuffers(2);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Pfe);
//---- name for DataWindow and indicator subwindow label
   short_name="PFE("+PfePeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//----
   SetIndexDrawBegin(0,PfePeriod);
   SetIndexBuffer(1,PfeBuffer);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Momentum                                                         |
//+------------------------------------------------------------------+
int start()
  {
   int i,k,counted_bars=IndicatorCounted();
   double noise=0;
//----
   if(Bars<=PfePeriod) return(0);

   i=Bars-PfePeriod-1;
   if(counted_bars>=PfePeriod) i=Bars-counted_bars-1;

   while(i>=0)
   {
      noise=0.000000001;
      for(k=0;k<PfePeriod;k++)
       {
        noise=noise+MathAbs(Close[i+k]-Close[i+k+1]);
       }
      PfeBuffer[i]=(Close[i]-Close[i+PfePeriod])/noise;
      i--;
   }

   i=Bars-PfePeriod-1;
   if(counted_bars>=PfePeriod) i=Bars-counted_bars-1;

   while(i>=0)     
   {
      if(UseAvarage)
        Pfe[i]=iMAOnArray(PfeBuffer,Bars,MaPeriod,0,MODE_EMA,i);
      else
        Pfe[i]=PfeBuffer[i];
      i--;
   }
  
   return(0);
  }
//+------------------------------------------------------------------+

Comments