2nd Order Gaussian High Pass Filter

Download script
Author: Copyright � 2005, Luis Guilherme Damiani
2nd Order Gaussian High Pass Filter

This technical tool is designed to assist traders in visualizing market momentum by calculating a specific mathematical flow on price data. Rather than looking at simple price movements, this script processes historical closing prices to create a smoothed trend line that helps filter out "market noise" or minor fluctuations.

How the Logic Works

The core functionality of this script relies on three main components:

1. Price Difference Analysis The tool looks at the relationship between the current price and the prices from the two preceding periods. By calculating these differences, it identifies the immediate direction and strength of the market movement. It essentially tries to determine if the price is accelerating, decelerating, or maintaining its current path.

2. Weighted Smoothing (The Alpha Factor) A key feature of this logic is the "Alpha" parameter. This acts as a sensitivity filter. Instead of reacting instantly and erratically to every tiny tick in the market, the script uses this weighting system to balance new information against historical data. This ensures that the resulting line on your chart represents a consistent trend rather than a jagged, erratic signal.

3. Recursive Momentum Calculation The script employs a recursive mathematical formula. This means that the value shown at any given moment is not just based on current price action alone; it incorporates a portion of the values from previous calculations. By blending the current momentum with a weighted average of past momentum, the tool produces a fluid, continuous line that highlights the underlying "pulse" of the market.

Summary for the User

In practical terms, this script generates a visual representation of price momentum. It takes raw price data, smooths out the minor distractions, and translates the "energy" of the market into a readable trend line. Traders can use this to identify whether a move has sustained strength or if the underlying momentum is beginning to fade, providing a clearer picture of the market's directionality.

Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
2nd Order Gaussian High Pass Filter
//+------------------------------------------------------------------+
//|                                               RAVI FX Fisher.mq4 |
//|                         Copyright © 2005, Luis Guilherme Damiani |
//|                                      http://www.damianifx.com.br |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Luis Guilherme Damiani"
#property link      "http://www.damianifx.com.br"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Lime
//#property indicator_color2 Red
//#property indicator_color3 Yellow

//---- input parameters
extern double       alpha=0.5;

extern int       maxbars=2000;


//---- buffers
double soHPF[];
//double SignalBuffer[];
//double AuxBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,soHPF);
 //  SetIndexStyle(1,DRAW_LINE);
 //  SetIndexBuffer(1,SignalBuffer);
 //  SetIndexStyle(2,DRAW_LINE);
//   SetIndexBuffer(2,AuxBuffer);
//   SetLevelValue(0,0.8);
//   SetLevelValue(1,-0.8);
   ArrayInitialize(soHPF,0);
//   ArrayInitialize(SignalBuffer,0);
//   ArrayInitialize(AuxBuffer,0);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
  {
      int    counted_bars=IndicatorCounted();
  //    Comment(Bars,"  ", counted_bars);
      //double Normalized=0;
      //double Fish=0;
      //---- check for possible errors
      if(counted_bars<0) return(-1);
      int limit=Bars-counted_bars;
      if(limit>maxbars)limit=maxbars;      
      //if (limit>Bars-1)limit=Bars-1;   
      //---- 
      for (int shift = limit; shift>=0;shift--)
      {
	      soHPF[shift]=MathPow(1-alpha/2,2)*(Close[shift] -2*Close[shift+1]+Close[shift+2])+2*(1-alpha)
	      *soHPF[shift+1]-MathPow(1-alpha,2)*soHPF[shift+2];
         
       }
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments