LaguerreFast

Download script
Author: Emerald King
LaguerreFast

This technical indicator is designed to provide a smoothed visual representation of market momentum and price behavior, specifically focusing on the relationship between successive price movements. Instead of simply looking at raw price data, it processes information through a specific mathematical framework to filter out "noise" and highlight underlying trends.

How the Logic Works

1. Data Smoothing (The Gamma Factor) The script uses a specific smoothing technique where it looks at the current closing price and balances it against previous calculations using a customizable sensitivity setting (Gamma). This prevents the indicator from reacting too wildly to minor, insignificant price fluctuations, ensuring that the resulting movement is fluid and more representative of the actual trend.

2. Layered Comparison The core logic functions by creating four distinct "levels" or layers of data based on historical prices. The script then performs a comparative analysis between these layers. It calculates the differences between these levels to determine whether the market is pushing forward (upward momentum) or pulling back (downward momentum).

3. Momentum Calculation By evaluating these differences, the script identifies the "Cumulative Upward" and "Cumulative Downward" forces within a specific window of time. It essentially asks: In the recent past, has the price been moving predominantly in one direction more than the other?

4. The Final Output (LRSI) The final result is expressed as a percentage-like value between 0 and 1. This means that:

  • A higher value indicates stronger upward momentum.
  • A lower value indicates stronger downward momentum.
  • The middle point serves as a baseline for the market's current bias.

Visual Representation

On your trading chart, this logic populates a separate window with a line that fluctuates between defined levels (0.775, 0.50, and 0.225). This allows you to see at a glance whether the market is overextended in one direction or if it is currently finding a balance point, helping you identify potential trend reversals or continuations more clearly than by looking at price alone.

17 Views
0 Downloads
0 Favorites
LaguerreFast
//+------------------------------------------------------------------+
//|                                                     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 LightSkyBlue
#property indicator_level2 0.775
#property indicator_level3 0.50
#property indicator_level4 0.225
#property indicator_maximum 1
#property indicator_minimum 0
//---- input parameters
extern double gamma = 0.2;
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;
//---- buffers
double val1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0, val1);
//----
   if (CountBars > Bars) 
       CountBars = Bars;
   SetIndexDrawBegin(0, Bars - CountBars);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
    int i;
    int    counted_bars = IndicatorCounted();
    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