This script is designed to provide a more refined and "smoothed" perspective on market momentum compared to standard technical indicators. Instead of reacting sharply to every minor price fluctuation, it uses a specialized mathematical process to filter out "noise," allowing traders to see the underlying trend more clearly.
How the Logic Works
1. Multi-Layered Smoothing The core logic relies on a series of overlapping calculations. Think of this like viewing a landscape through different lenses: each layer captures a slightly different nuance of price movement. By layering these together, the script creates a stabilized path that doesn't jump erratically. It balances current price data with past data to ensure that the resulting values move in a fluid, consistent manner.
2. Momentum Calculation Once the smoothing is complete, the script analyzes the "velocity" of the price. It calculates both the upward and downward movements across the different layers it has created. By identifying how much the price is pushing in one direction versus the other, it determines the relative strength of the current market trend.
3. The Final Result (Relative Strength) The final output is a ratio that represents the balance between these two forces. It answers the question: “Of all the movement happening right now, what percentage of it is moving in the positive direction versus the negative?”
Summary for Traders
In practical terms, this script helps identify whether the market is gaining strength or losing steam without the "jittery" signals often found in basic indicators. It provides a stabilized momentum reading that helps in identifying established trends and potential turning points by smoothing out the emotional highs and lows of price action.
//+------------------------------------------------------------------+
//| Collaps.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, SanSey"
#property link "http://www.forexchat.ru"
#property library
double LaGuerre(double gamma, int shift)
{
double RSI;
double L0[100];
double L1[100];
double L2[100];
double L3[100];
double CU, CD;
for (int i=shift+99; i>=shift; i--)
{
L0[i] = (1.0 - gamma)*Close[i] + gamma*L0[i+1];
L1[i] = -gamma*L0[i] + L0[i+1] + gamma*L1[i+1];
L2[i] = -gamma*L1[i] + L1[i+1] + gamma*L2[i+1];
L3[i] = -gamma*L2[i] + L2[i+1] + gamma*L3[i+1];
CU = 0; CD = 0;
if (L0[i]>=L1[i]) CU= L0[i]-L1[i]; else CD=L1[i]-L0[i];
if (L1[i]>=L2[i]) CU=CU+L1[i]-L2[i]; else CD=CD+L2[i]-L1[i];
if (L2[i]>=L3[i]) CU=CU+L2[i]-L3[i]; else CD=CD+L3[i]-L2[i];
if (CU + CD != 0) RSI = CU/(CU+CD);
}
return(RSI);
}
Comments