mirror of
https://github.com/softwaredevelop/mql5.git
synced 2026-08-19 23:38:07 +00:00
refactor: Added selectable signal line type
This commit is contained in:
+13
-18
@@ -6,46 +6,41 @@ The `MACD_Laguerre_Histogram_Pro` is the dedicated histogram component for our L
|
||||
|
||||
This indicator visually represents the convergence and divergence of momentum. The height and depth of the histogram bars provide an immediate sense of momentum acceleration and deceleration.
|
||||
|
||||
It is designed as a **companion indicator** to be overlaid in the same window as the `MACD_Laguerre_Line_Pro`. When their parameters are synchronized, they form a complete, modern, and highly responsive MACD system. The signal line's smoothing method is user-selectable from the four standard moving average types (SMA, EMA, SMMA, LWMA).
|
||||
It is designed as a **companion indicator** to be overlaid in the same window as the `MACD_Laguerre_Line_Pro`. When their parameters are synchronized, they form a complete, modern, and highly responsive MACD system. The signal line's smoothing method is user-selectable, offering a choice between a **Laguerre filter** or one of the four standard moving average types (SMA, EMA, SMMA, LWMA).
|
||||
|
||||
## 2. Mathematical Foundations and Calculation Logic
|
||||
|
||||
To ensure perfect synchronization and accuracy without external dependencies, this indicator performs the full MACD calculation internally before outputting only the histogram.
|
||||
|
||||
### Required Components
|
||||
|
||||
* **Fast Gamma ($\gamma_{fast}$)** and **Slow Gamma ($\gamma_{slow}$)** for the MACD Line.
|
||||
* **Signal Line Period (S)** and **MA Type** for the Signal Line.
|
||||
* **Source Price (P)**.
|
||||
|
||||
### Calculation Steps (Algorithm)
|
||||
|
||||
1. **Calculate the MACD Line:** First, a fast and a slow Laguerre filter are calculated on the source price. The MACD Line is their difference.
|
||||
* $\text{MACD Line}_t = \text{LaguerreFilter}(P, \gamma_{fast})_t - \text{LaguerreFilter}(P, \gamma_{slow})_t$
|
||||
|
||||
2. **Calculate the Signal Line:** A moving average (of the user-selected type) is applied to the MACD Line calculated in the previous step.
|
||||
* $\text{Signal Line}_t = \text{MA}(\text{MACD Line}, S)_t$
|
||||
2. **Calculate the Signal Line:** A smoothing of the user-selected type (`MA Type`) is applied to the `MACD Line` calculated in the previous step.
|
||||
* $\text{Signal Line}_t = \text{Smoothing}(\text{MACD Line}, \text{Parameters})_t$
|
||||
|
||||
3. **Calculate the Histogram:** The final output is the difference between the MACD Line and the Signal Line.
|
||||
* $\text{Histogram}_t = \text{MACD Line}_t - \text{Signal Line}_t$
|
||||
|
||||
## 3. MQL5 Implementation Details
|
||||
|
||||
* **Self-Contained Calculation:** The indicator is fully self-contained. To guarantee accuracy, its engine (`MACD_Laguerre_Histogram_Calculator.mqh`) internally recalculates the entire Laguerre MACD line using the `Laguerre_Engine`. This "shared engine" architecture avoids the instability of `iCustom` calls and ensures that the histogram is always perfectly synchronized with its corresponding line indicator, provided the inputs match.
|
||||
* **Self-Contained Calculation:** The indicator is fully self-contained. Its engine (`MACD_Laguerre_Histogram_Calculator.mqh`) internally recalculates the entire Laguerre MACD line using the `Laguerre_Engine`. This "shared engine" architecture avoids the instability of `iCustom` calls.
|
||||
|
||||
* **Reusable Components:** The calculator efficiently reuses our modular components:
|
||||
* It contains two instances of `CLaguerreEngine` to generate the base MACD line.
|
||||
* It uses our universal `CalculateMA` helper function to apply the selected moving average for the signal line.
|
||||
* **Flexible Signal Line Calculation:** The calculator uses a `switch` block to apply the user's chosen smoothing method for the signal line. This includes a dedicated, state-managed calculation for the `Laguerre` option and reuses our universal `CalculateMA` helper function for standard MA types.
|
||||
|
||||
* **Object-Oriented Design (Inheritance):** The standard `_HA` derived class architecture is used to seamlessly support calculations on Heikin Ashi price data.
|
||||
|
||||
## 4. Parameters
|
||||
|
||||
* **Gamma 1 (`InpGamma1`):** The gamma coefficient for one of the base Laguerre filters (e.g., `0.2` for fast).
|
||||
* **Gamma 2 (`InpGamma2`):** The gamma coefficient for the other base Laguerre filter (e.g., `0.8` for slow).
|
||||
* **Signal Period (`InpSignalPeriod`):** The lookback period for the signal line's moving average. Default is `9`.
|
||||
* **Signal MA Type (`InpSignalMAType`):** The type of moving average to use for the signal line (SMA, EMA, SMMA, LWMA). Default is `EMA`.
|
||||
* **Applied Price (`InpSourcePrice`):** The source price for the calculation (Standard or Heikin Ashi).
|
||||
* **Laguerre MACD Settings:**
|
||||
* **`InpGamma1` / `InpGamma2`:** The gamma coefficients for the two base Laguerre filters. The smaller value will be the fast filter, the larger will be the slow one.
|
||||
* **Signal Line Settings:**
|
||||
* **`InpSignalMAType`:** A dropdown menu to select the smoothing type for the signal line. Options include `Laguerre`, `SMA`, `EMA`, `SMMA`, `LWMA`.
|
||||
* **`InpSignalPeriod`:** The lookback period for **standard MA** signal lines.
|
||||
* **`InpSignalGamma`:** The gamma coefficient used **only** if the signal line type is set to `Laguerre`.
|
||||
* **Price Source:**
|
||||
* **`InpSourcePrice`:** The source price for the calculation (Standard or Heikin Ashi).
|
||||
|
||||
## 5. Usage and Interpretation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user