Laguerre_001
Download scriptThis technical tool is designed to provide a visual representation of market momentum by analyzing price trends over a specific historical period. Instead of looking at raw price movements, it processes the data into a specialized smoothed value that helps traders identify whether the current market movement is gaining strength or losing steam.
How the Logic Works
The script operates through three primary stages to transform raw market data into a readable indicator:
1. Data Smoothing and Stabilization The tool begins by applying a smoothing factor (determined by the "gamma" setting) to the closing prices of the assets. Rather than reacting impulsively to every tiny price flicker, it blends current prices with historical averages. This creates a "steady" path that filters out market noise while still staying responsive to significant trends.
2. Multi-Layered Trend Tracking The logic creates four distinct layers of data points (L0 through L3). Think of these as four different "shadows" of the price moving at slightly different speeds or intensities. By tracking how these four layers interact with one another, the tool can sense subtle shifts in the market structure that might not be visible to the naked eye on a standard price chart.
3. Momentum Calculation (The Relative Strength) Once these layers are established, the script calculates the "upward" versus "downward" movements between them:
- It measures the distance gained by one layer over another in an upward direction.
- It measures the distance lost in a downward direction.
- It then combines these values to produce a final percentage-based score.
Visual Interpretation
The final output is displayed in a separate window as a single line. This line fluctuates based on the balance of power in the market:
- High Values: Indicate that upward momentum is dominant.
- Low Values: Indicate that downward pressure is taking over.
- Neutral Zones: The tool includes specific horizontal levels (0.80, 0.50, and 0.20) to help users easily identify when the market is reaching extremes or sitting in a balanced state.
By using this method, the script offers a clearer picture of "market sentiment," helping you see where the trend is heading rather than just where the price has been.
#property indicator_separate_window
#property indicator_color1 Magenta
#property indicator_level2 0.80
#property indicator_level3 0.50
#property indicator_level4 0.20
//---- input parameters
extern double gamma=0.7;
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