Laguerre_ROC_v2
Download scriptThis tool is a specialized financial analysis indicator designed to help traders visualize market momentum and price velocity. Rather than simply looking at the raw price of an asset, it processes data to identify the underlying "strength" or "speed" of the current market move.
How the Logic Works
1. Data Input & Price Change Tracking The indicator begins by looking back at a specific number of historical candles (defined by the user). It calculates the Rate of Change (ROC) by comparing the current closing price to the price from a set period in the past. This tells the tool how much the price has moved and in which direction.
2. The Smoothing Mechanism (Laguerre Filtering) To prevent the data from being too "noisy" or erratic—which can often lead to false signals—the script uses a mathematical smoothing technique. It takes the raw rate of change and blends it with previous calculations using a specific weight (Gamma). This creates a fluid, continuous flow of data that highlights the trend while filtering out minor market fluctuations.
3. Momentum Analysis The core logic then compares multiple layers of these smoothed values against one another. It treats these layers like different "gears" of a machine:
- It identifies whether each layer is currently higher or lower than the one preceding it.
- It calculates the difference between these layers to determine the "Cumulative Upward" or "Cumulative Downward" pressure.
4. The Final Output The final value displayed on your chart is a ratio of this upward versus downward pressure.
- When the Upward Pressure outweighs the Downward Pressure, the indicator reflects a positive momentum.
- When the Downward Pressure takes over, it reflects a negative momentum.
Key Takeaways for the User
- Trend Identification: Instead of just seeing a price line, you are seeing a "momentum score." It helps you see if the market is gaining steam or losing energy.
- Stability: Because it uses a smoothing algorithm (Laguerre), the indicator is designed to be less jumpy than standard momentum oscillators, making it easier to follow the primary trend.
- Visual Interpretation: The indicator operates within a specific range (from -0.10 to 1.10). By watching how the line moves relative to the horizontal levels on your screen, you can better judge whether the market's current "speed" is accelerating or decelerating.
//+------------------------------------------------------------------+
//| 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