mirror of
https://github.com/softwaredevelop/mql5.git
synced 2026-08-06 09:07:45 +00:00
new files added
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
# Laguerre RSI Professional
|
||||
|
||||
## 1. Summary (Introduction)
|
||||
|
||||
The Laguerre RSI, developed by the renowned digital signal processing (DSP) expert John Ehlers, is a sophisticated and modern version of the classic Relative Strength Index (RSI). Its core innovation is the use of a **Laguerre filter** to smooth the price data before the RSI calculation is applied.
|
||||
|
||||
The result is an oscillator that is exceptionally **smooth** and produces significantly less noise and fewer "whipsaws" than a traditional RSI. Despite its smoothness, it remains highly responsive to changes in market momentum, making it a powerful tool for identifying overbought/oversold conditions and potential trend reversals.
|
||||
|
||||
Our `Laguerre_RSI_Pro` implementation is a unified, professional version that allows the calculation to be based on either **standard** or **Heikin Ashi** price data.
|
||||
|
||||
## 2. Mathematical Foundations and Calculation Logic
|
||||
|
||||
The indicator's logic is a two-stage process: first, the price is filtered, and then an RSI-like formula is applied to the filter's components.
|
||||
|
||||
### Required Components
|
||||
|
||||
* **Gamma (γ):** A single coefficient between 0 and 1 that controls the smoothing and responsiveness of the Laguerre filter.
|
||||
* **Source Price (P):** The price series used for the calculation.
|
||||
|
||||
### Calculation Steps (Algorithm)
|
||||
|
||||
The calculation is highly recursive, relying on the state of four internal filter components from the previous bar (`L0`, `L1`, `L2`, `L3`).
|
||||
|
||||
1. **Initialize Filter:** For the first bar, all `L` components are initialized with the current price.
|
||||
2. **Calculate Laguerre Filter Components:** For each subsequent bar `i`, the filter components are updated based on the previous bar's values:
|
||||
* $L0_i = (1 - \gamma) \times P_i + \gamma \times L0_{i-1}$
|
||||
* $L1_i = -\gamma \times L0_i + L0_{i-1} + \gamma \times L1_{i-1}$
|
||||
* $L2_i = -\gamma \times L1_i + L1_{i-1} + \gamma \times L2_{i-1}$
|
||||
* $L3_i = -\gamma \times L2_i + L2_{i-1} + \gamma \times L3_{i-1}$
|
||||
3. **Calculate RSI-like Sums:** The "up" and "down" sums (`cu` and `cd`) are calculated from the differences between the filter components:
|
||||
* `cu = 0`, `cd = 0`
|
||||
* If $L0_i \ge L1_i$, then `cu += L0_i - L1_i`, else `cd += L1_i - L0_i`
|
||||
* If $L1_i \ge L2_i$, then `cu += L1_i - L2_i`, else `cd += L2_i - L1_i`
|
||||
* If $L2_i \ge L3_i$, then `cu += L2_i - L3_i`, else `cd += L3_i - L2_i`
|
||||
4. **Calculate Final Laguerre RSI Value:**
|
||||
* $\text{Laguerre RSI}_i = 100 \times \frac{cu}{cu + cd}$
|
||||
* The final value is clamped to the range to handle minor floating-point overflows.
|
||||
|
||||
## 3. MQL5 Implementation Details
|
||||
|
||||
* **Modular Calculation Engine (`Laguerre_RSI_Calculator.mqh`):**
|
||||
The entire complex, recursive calculation is encapsulated within a reusable `CLaguerreRSICalculator` class. This separates the mathematical logic from the indicator's user interface.
|
||||
* **Heikin Ashi Integration:** An inherited `CLaguerreRSICalculator_HA` class allows the calculation to be performed seamlessly on smoothed Heikin Ashi data by simply overriding the initial data preparation step.
|
||||
* **Stability via Full Recalculation:** We employ a "brute-force" full recalculation within `OnCalculate`. For a highly state-dependent and recursive filter like Laguerre, this is the most robust and reliable method, eliminating potential desynchronization errors common with `prev_calculated` logic.
|
||||
* **Value Clamping:** The final calculated value is mathematically clamped to the 0-100 range to ensure it always fits perfectly within the standard oscillator window, even with extreme market conditions.
|
||||
|
||||
## 4. Parameters
|
||||
|
||||
* **Gamma (`InpGamma`):** The Laguerre filter coefficient, a value between 0.0 and 1.0. This is the most important parameter and controls the indicator's speed.
|
||||
* **Low Gamma (e.g., 0.1 - 0.3):** Slower, smoother line. Good for high-level trend filtering on higher timeframes.
|
||||
* **Medium Gamma (e.g., 0.4 - 0.6):** A balanced setting, offering good smoothing while remaining responsive. An excellent starting point for most strategies.
|
||||
* **High Gamma (e.g., 0.7 - 0.9):** Faster, more responsive line. Suitable for scalping on lower timeframes, but more prone to noise.
|
||||
* **Applied Price (`InpSourcePrice`):** The source price for the calculation. This unified dropdown menu allows you to select from all standard and Heikin Ashi price types.
|
||||
|
||||
## 5. Usage and Interpretation
|
||||
|
||||
The Laguerre RSI's primary advantage is its clarity and smoothness, making classic oscillator strategies more effective.
|
||||
|
||||
### **1. Overbought / Oversold Reversals**
|
||||
|
||||
This is the most common use. Due to its "sharp" turning behavior, levels like 80/20 or even 90/10 are often more effective than the traditional 70/30.
|
||||
|
||||
* **Buy Signal:** The indicator line crosses up from below the oversold level (e.g., 20). This suggests bearish momentum is exhausted.
|
||||
* **Sell Signal:** The indicator line crosses down from above the overbought level (e.g., 80). This suggests bullish momentum is exhausted.
|
||||
* **Best Use:** This strategy works best in **ranging or consolidating markets**.
|
||||
|
||||
### **2. Centerline Crossover (Trend Following)**
|
||||
|
||||
The 50-level acts as a balance point between bullish and bearish momentum.
|
||||
|
||||
* **Bullish Filter:** When the Laguerre RSI is **above 50**, the momentum is considered bullish. Traders may look for long entries and avoid short positions.
|
||||
* **Bearish Filter:** When the Laguerre RSI is **below 50**, the momentum is considered bearish.
|
||||
|
||||
### **3. Divergence (Advanced Reversal Signal)**
|
||||
|
||||
Divergence is one of the most powerful signals, and it is often very clear on the smooth Laguerre RSI line.
|
||||
|
||||
* **Bullish Divergence:** Price makes a **new lower low**, but the Laguerre RSI makes a **higher low**. This indicates weakening sell pressure and a potential bottom.
|
||||
* **Bearish Divergence:** Price makes a **new higher high**, but the Laguerre RSI makes a **lower high**. This indicates weakening buy pressure and a potential top.
|
||||
|
||||
### **4. Exit Strategies (Example for a Long Position)**
|
||||
|
||||
* **Conservative (Quick Profit):** Exit when the indicator crosses into the overbought zone (e.g., above 80).
|
||||
* **Balanced (Trend Following):** Hold the position as long as the indicator stays above the 50 centerline. Exit when it crosses below 50.
|
||||
* **Advanced (Peak Exit):** Hold the position until a clear bearish divergence forms.
|
||||
Reference in New Issue
Block a user