Laguerre_ROC_v1

Download script
Laguerre_ROC_v1

This tool is designed as a specialized technical analysis indicator for the MetaTrader platform. Its primary purpose is to measure and visualize momentum by analyzing how the price of an asset changes over a specific period, while smoothing out minor fluctuations to reveal clearer trends.

Core Logic and Mechanics

1. Momentum Calculation The script begins by calculating the "Rate of Change." It looks back at a user-defined number of candles (the Period) and compares the current closing price against the closing price from that past point. By determining the percentage difference between these two points, the tool establishes a baseline for how fast the price is moving in a specific direction.

2. The Laguerre Filtering System To prevent the data from being too "noisy" or erratic, the script employs a series of mathematical filters known as Laguerre equations. Rather than just showing raw jumps in price, it uses a smoothing factor (Gamma) to blend current momentum with historical data. This creates a balanced view where the indicator remains responsive to new price action but is shielded from insignificant market "jitters."

3. Directional Weighting The logic processes three distinct layers of these smoothed values. By comparing these layers against one another, the script can determine the relative strength of upward versus downward movement. It calculates the cumulative difference between these layers to see which direction is gaining more "weight" or authority.

4. Final Output (LROC) The final result displayed on your chart is a normalized value. The script takes the total upward momentum and divides it by the combined total of both upward and downward movements. This produces a streamlined indicator that tells you the intensity of the current trend:

  • A higher positive value suggests strong upward momentum.
  • A lower or negative value suggests downward pressure.

Summary for the Trader

In simple terms, this script acts as a "momentum stabilizer." It watches how fast the price is moving, filters out the distracting noise of the market using specialized smoothing math, and presents you with a clean representation of whether the current trend has actual strength or if it is merely a temporary fluctuation.

9 Views
0 Downloads
0 Favorites
Laguerre_ROC_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                 Laguerre_ROC.mq4 |
//|                                             Emerald King , MTE&I |
//+------------------------------------------------------------------+

#property indicator_separate_window

#property indicator_color1 Red

#property indicator_level2 1.00
#property indicator_level3 0.75
#property indicator_level4 0.50
#property indicator_level5 0.25
#property indicator_level6 0.00

#property indicator_maximum  1.10
#property indicator_minimum -0.10

//---- input parameters
extern int    vPeriod   =     5;
extern double gamma     = 0.500;
extern int    CountBars =  3000;

double ROC = 0;
double L0 = 0;
double L1 = 0;
double L2 = 0;
double L3 = 0;
double L0A = 0;
double L1A = 0;
double L2A = 0;
double L3A = 0;
double LROC = 0;
double CU = 0;
double CD = 0;

double val1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   SetIndexBuffer(0,val1);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   if (CountBars>Bars) CountBars=Bars;
   SetIndexDrawBegin(0,Bars-CountBars);
   
   int i;
   int counted_bars=IndicatorCounted();

   i = CountBars-1;
   while(i>=0)
   {
      L0A = L0;
      L1A = L1;
      L2A = L2;
      L3A = L3;
      
      ROC = (((Close[i] - Close[i + vPeriod]) / Close[i + vPeriod]) + Point);
      L0 = ((1 - gamma)*(ROC)) + (gamma*L0A);
      
      L1 = - gamma *L0 + L0A + gamma *L1A;
      L2 = - gamma *L1 + L1A + gamma *L2A;
      L3 = - gamma *L2 + L2A + gamma *L3A;

      CU = 0;
      CD = 0;
      
      if (L0 >= L1) CU = L0 - L1; else CD = L1 - L0;
      if (L1 >= L2) CU = CU + L1 - L2; else CD = CD + L2 - L1;
      if (L2 >= L3) CU = CU + L2 - L3; else CD = CD + L3 - L2;

      if (CU + CD != 0) LROC = CU / (CU + CD);
      val1[i] = LROC;
	  i--;
	}
   return(0);
 }
//+------------------------------------------------------------------+

Comments