new files added

This commit is contained in:
Toh4iem9
2026-06-30 14:24:52 +02:00
parent ebe4f279a6
commit e7234ae129
@@ -0,0 +1,160 @@
# Laguerre Stochastic Fast & Slow Pro Suites (Standard & MTF)
## 1. Summary (Introduction)
The **Laguerre Stochastic Fast & Slow Pro Suites** are institutional-grade, cycle-isolation trading suites comprising four advanced indicators:
* `Laguerre_Stoch_Fast_Pro` (Standard Fast)
* `Laguerre_Stoch_Fast_MTF_Pro` (Multi-Timeframe Fast)
* `Laguerre_Stoch_Slow_Pro` (Standard Slow)
* `Laguerre_Stoch_Slow_MTF_Pro` (Multi-Timeframe Slow)
Traditional Stochastic Oscillators measure the relative position of the current closing price within a rigid, time-based high-low window (e.g., 14 periods). During strong trends, standard stochastics suffer from extreme saturation, remaining pinned at oversold or overbought levels and rendering them useless for cycle detection.
John Ehlers resolved this limitation by applying Stochastic mathematics directly to the four state registers ($L_0$ to $L_3$) of his **Laguerre Filter**. Because the Laguerre Filter dampens noise recursively in polynomial space, the resulting **Laguerre Stochastic** measures the relative acceleration and compression of price cycles with near-zero lag, generating responsive, highly defined wave oscillations.
The suites support dynamic Heikin Ashi price integration, three-decimal Gamma formatting to support precise **Fibonacci ratios**, and advanced volume-weighted smoothing (**VWMA**) on slowing and signal lines.
---
## 2. Mathematical Foundations
The core calculation operates by transforming price coordinates into Laguerre space and then measuring the elatibility of the current state register ($L_0$) relative to the boundary range established by all four polynomial registers:
### A. Dynamic Polynomial Boundaries
On each bar $t$, the Laguerre states ($L_{0, t}$ to $L_{3, t}$) are updated recursively using the dampening factor $\gamma$ (`InpGamma`). The maximum and minimum values among these four states are determined dynamically:
$$H_t = \max(L_{0, t}, L_{1, t}, L_{2, t}, L_{3, t})$$
$$L_t = \min(L_{0, t}, L_{1, t}, L_{2, t}, L_{3, t})$$
$$\text{Range}_t = H_t - L_t$$
### B. Fast Stochastic %K Calculation
The raw (Fast) Stochastic $\%K_{\text{Fast}}$ measures where the current state $L_{0, t}$ is located within this dynamic polynomial range:
$$\%K_{\text{Fast}, t} = \frac{L_{0, t} - L_t}{\text{Range}_t} \times 100$$
To protect the system from division-by-zero errors during absolute price consolidation, the calculator incorporates an active fallback gate:
$$\%K_{\text{Fast}, t} = \begin{cases}
\%K_{\text{Fast}, t-1} & \text{if } \text{Range}_t \le 1.0 \times 10^{-9} \text{ and } t > 0 \\
50.0 & \text{if } \text{Range}_t \le 1.0 \times 10^{-9} \text{ and } t = 0
\end{cases}$$
### C. Slow Stochastic %K and %D Calculations
* **Fast %K Signal:**
The `Stoch_Fast` indicators calculate a single Signal line by smoothing the raw $\%K_{\text{Fast}}$ over `InpSignalPeriod`:
$$\text{Signal}_t = \text{MA}(\%K_{\text{Fast}}, \text{SignalPeriod})_t$$
* **Slow %K Smoothing:**
The `Stoch_Slow` indicators apply a smoothing average (Slowing) over the raw $\%K_{\text{Fast}}$ to establish the **Slow %K** line, filtering out high-frequency noise:
$$\%K_{\text{Slow}, t} = \text{MA}(\%K_{\text{Fast}}, \text{SlowingPeriod})_t$$
* **Slow Signal %D:**
The Slow Signal $\%D_{\text{Slow}}$ is generated by applying a secondary moving average directly over the Slow %K line over `InpSignalPeriod`:
$$\%D_{\text{Slow}, t} = \text{MA}(\%K_{\text{Slow}}, \text{SignalPeriod})_t$$
Both the slowing and signal engines natively support standard moving averages (SMA, EMA, SMMA, LWMA, TMA, DEMA, TEMA) and **Volume-Weighted Moving Averages (VWMA)** to incorporate trade volume into cycle reversals.
---
## 3. High-Performance & Precision Enhancements
The suites leverage several advanced MQL5 architectural design patterns:
* **Three-Decimal Precision Formatting:**
To natively support precise Fibonacci Gamma inputs (e.g., `0.236`, `0.382`, `0.618`) without visual rounding, the indicator short name formatting is expanded to three decimal places. The dynamic ShortName in `OnInit()` uses a `%.3f` formatting mask:
```mql5
IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("Laguerre Stoch Slow(%.3f, %d, %d)", InpGamma, InpSlowingPeriod, InpSignalPeriod));
```
* **Strict Chronological Sorting Safeguards:**
To prevent calculation corruption caused by reverse-chronological array states (often forced by custom templates or third-party indicators on the active chart), the suite enforces chronological sorting (`ArraySetAsSeries(..., false)`) on all price inputs inside `OnCalculate()`.
* **Memory Safety Validation (Pointer Guards):**
To shield the terminal from runtime memory violations (such as access violation fatal crashes), a robust pointer-safety layer validates all dynamic objects via `CheckPointer()` before any calculation sequence is allowed to execute.
---
## 4. Advanced MQL5 MTF Implementation Details
Both the Fast and Slow MTF versions resolve standard MTF calculation and display limitations by implementing a synchronized multi-timeframe pipeline:
### A. Forming LTF Block Flat-Force (The Warping Solution)
To prevent real-time step warping and slope distortion on lower timeframe charts, the indicator implements a step-blocking algorithm. On every tick, the indicator isolates the beginning of the active forming HTF block and forces the calculations to rewrite that block completely, keeping the visual lines perfectly flat and historically stable:
```mql5
int first_bar_of_forming_htf = rates_total - 1;
while(first_bar_of_forming_htf > 0 &&
iBarShift(_Symbol, g_calc_timeframe, time[first_bar_of_forming_htf], false) == 0)
{
first_bar_of_forming_htf--;
}
first_bar_of_forming_htf++; // Dynamic anchor start
if(start > first_bar_of_forming_htf)
start = first_bar_of_forming_htf;
```
### B. State Mocking for IIR State Stability
Since the Laguerre Filter is highly recursive, calling calculations continuously on the live forming bar on every tick would corrupt the feedback states ($L_0$ to $L_3$). To avoid this, we perform **State Mocking** by passing `prev_calculated = g_htf_count` during live ticks. This processes the forming index exactly once, protecting closed historical registers from accumulation errors.
---
## 5. Parameters
### A. Laguerre Settings
* **Gamma Factor (`InpGamma`):** Controls the responsiveness of the underlying Laguerre Filter baseline. Lower values (e.g., `0.382` or `0.500`) are faster; higher values (e.g., `0.700` or `0.850`) are smoother (Default: `0.700`, Fibonacci Recommendations: `0.236`, `0.382`, `0.618`).
* **Source Price (`InpSourcePrice`):** Selects the pricing input, supporting Standard and Heikin Ashi price series (Default: `PRICE_CLOSE_STD`).
### B. Signal / Stochastic Settings
* **Slowing Period (`InpSlowingPeriod` - Slow Version Only):** The smoothing lookback period for Fast %K to establish Slow %K (Default: `3`).
* **Slowing Method (`InpSlowingMethod` - Slow Version Only):** The MA type used for Slowing (Default: `SMA`). Supports `VWMA`.
* **Signal Period (`InpSignalPeriod`):** The lookback period for the Signal line (Default: `3`).
* **Signal Method (`InpSignalMethod`):** The MA type used for the Signal line (Default: `SMA`). Supports `VWMA`.
### C. MTF Specific Settings (MTF Versions Only)
* **Target Timeframe (`InpUpperTimeframe`):** The target higher timeframe to calculate Laguerre Stochastics on (Default: `PERIOD_H1`).
---
## 6. Quantitative Trading Strategies
### A. Fast Momentum Exhaustion Scalping (Fast %K Reversal)
Because the Fast Stochastic calculates states directly inside Laguerre space with near-zero lag, its extreme turns represent highly accurate, temporary momentum exhaustions.
1. **Setup:** Open `Laguerre_Stoch_Fast_Pro` configured with a fast Fibonacci Gamma of **`0.382`** (highly responsive execution baseline).
2. **Oversold Reversal (BUY):**
* Wait for the Fast %K line to touch or drop below **`10.0`**, indicating extreme downward exhaustion in Laguerre space.
* Wait for Fast %K to **cross back above its Signal line** and rise above `10.0`/`20.0`.
* **Execution:** Open Long. Place stop-loss strictly below the local swing low.
3. **Overbought Reversal (SELL):**
* Wait for Fast %K to rise above **`90.0`**.
* Wait for Fast %K to **cross back below its Signal line** and drop below `90.0`/`80.0`.
* **Execution:** Open Short. Place stop-loss strictly above the local swing high.
### B. Dynamic VWMA Volume-Confirmed Trend Following (Slow %K / %D Corridor)
Using the Slow Stochastic with VWMA smoothing filters out low-volume, sideways price actions, ensuring that trend entries are backed by institutional volume.
1. **Setup:** Open `Laguerre_Stoch_Slow_Pro` on an M15 execution chart with the following settings:
* `InpGamma = 0.618` (The Golden Ratio anchor)
* `InpSlowingPeriod = 3` (MA Type: `VWMA`)
* `InpSignalPeriod = 3` (MA Type: `VWMA`)
2. **Bullish Trend Trigger (BUY):**
* Wait for the Slow %K line (blue) to cross above the Signal %D line (coral) while both lines are rising from below the `20.0` or `50.0` level.
* Because both smoothing loops are configured to `VWMA`, the crossover will only occur if the cyclical turning point is backed by an increase in real trading volume.
* **Execution:** Open Long. Place a trailing stop-loss strictly below the Slow %K line.
3. **Bearish Trend Trigger (SELL):**
* Wait for the Slow %K line to cross below the Signal %D line while both lines are falling from above the `80.0` or `50.0` level.
* **Execution:** Open Short.