Laguerre_v1

Download script
Author: Emerald King
Laguerre_v1

This tool is designed as a specialized visual indicator for trading platforms, specifically engineered to help traders interpret market momentum and price trends. Rather than showing simple price action, it calculates a sophisticated mathematical progression to smooth out market "noise," allowing for a clearer view of the underlying movement.

Core Methodology

The logic operates by creating a series of four distinct moving layers (referred to as L0 through L3). It processes these layers using a specific weighting system—governed by a "Gamma" variable—which determines how much influence new price data has compared to historical data.

By linking these four layers together, the script creates a rolling calculation where each subsequent layer reacts slightly differently to current price changes. This allows the tool to identify the "velocity" of the market rather than just its current position.

Momentum Detection

Once these four layers are established, the indicator performs a comparative analysis:

  • Upward Movement: It measures the positive gaps between the layers when they move in an ascending fashion.
  • Downward Movement: It measures the negative gaps between the layers when they move in a descending fashion.

By weighing these two types of movements against each other, the script calculates a specific ratio. This ratio is then displayed as a visual line in a separate window on your chart.

How to Interpret the Results

The final output represents a normalized momentum value.

  • When the indicator moves toward the top of its range, it suggests that the upward momentum is currently outweighing the downward pressure.
  • When it moves toward the bottom, it indicates that downward momentum is prevailing.

In essence, this script acts as a "smoothing" filter that translates raw price fluctuations into a more digestible trend line, helping traders see whether the market's current direction has sustained strength or is beginning to lose steam.

8 Views
0 Downloads
0 Favorites
Laguerre_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                     Laguerre.mq4 |
//|                                                     Emerald King |
//|                                     mailto:info@emerald-king.com |
//+------------------------------------------------------------------+
#property copyright "Emerald King"
#property link      "mailto:info@emerald-king.com"

#property indicator_separate_window
#property indicator_color1 Blue
//---- input parameters
extern double gamma=0.5;
extern int CountBars=950;

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 LRSI = 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();

   //if(CountBars<=Lookback) return(0);
   //---- initial zero
   //if(counted_bars<1)
   //{
   //   for(i=1;i<=Lookback;i++) val1[CountBars-i]=0.0;
   //}

   i=CountBars-1;
   while(i>=0)
   {
      L0A = L0;
      L1A = L1;
      L2A = L2;
      L3A = L3;
      L0 = (1 - gamma)*Close[i] + 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) LRSI = CU / (CU + CD);
      val1[i] = LRSI;
	  i--;
	}
   return(0);
 }
//+------------------------------------------------------------------+

Comments