mirror of
https://github.com/softwaredevelop/mql5.git
synced 2026-11-02 11:16:15 +00:00
docs: refactor
This commit is contained in:
+259
-131
@@ -1,154 +1,153 @@
|
||||
# John Ehlers' Laguerre Relative Strength Index (Laguerre RSI) Pro (v3.00)
|
||||
# Laguerre Relative Strength Index (LRSI) Pro (v3.10)
|
||||
|
||||
Quantitative Time-Warped Zero-Lag Momentum & Relative Strength Oscillator Suite
|
||||
John Ehlers' Canonical Time-Warped Momentum Oscillator with Zero-Copy Memory & Zero-Lag MTF Fast-Path
|
||||
|
||||
---
|
||||
|
||||
## 1. Summary (Introduction)
|
||||
|
||||
**Laguerre RSI Pro** is an institutional-grade non-linear momentum oscillator developed by aerospace engineer and quantitative trading pioneer John Ehlers.
|
||||
**Laguerre RSI Pro (v3.10)** is an institutional-grade cycle and momentum oscillator implementing John Ehlers' classical **Time-Warped Laguerre Relative Strength Index (LRSI)**.
|
||||
|
||||
In classical technical analysis, J. Welles Wilder Jr.'s standard Relative Strength Index (RSI) averages price gains and losses over a fixed 14-bar lookback window, introducing unavoidable phase lag and slow signal resolution. **John Ehlers resolved this by applying the RSI mathematical concept across four orthogonal Laguerre polynomial state registers ($L_0, L_1, L_2, L_3$)**:
|
||||
While standard Welles Wilder RSI operates with linear unit delays across fixed lookback windows (typically 14 periods)—introducing severe phase lag and frequent whipsaws during market consolidation—**Laguerre RSI processes price action through an all-pass filter network driven by orthogonal Laguerre polynomials ($L_0, L_1, L_2, L_3$)**.
|
||||
|
||||
* **Zero Historical Lookback Overhead:** Rather than calculating across $N$ price bars, Laguerre RSI evaluates the instantaneous directional displacement between the four Laguerre filter stages.
|
||||
* **Near-Zero Phase Lag Inflections:** The time-warped all-pass transfer function enables the oscillator to recognize market cyclical turns with virtually zero phase delay.
|
||||
* **Bounded 0–100 Scale with Clear Extremes:** Provides precise, non-lagging overbought ($\ge 80.0 / 90.0$) and oversold ($\le 20.0 / 10.0$) reversal thresholds.
|
||||
By measuring directional differences strictly between adjacent polynomial states rather than raw historic bars, Laguerre RSI concentrates higher-order spectral power into just four recursive registers, providing near-zero phase delay and instantaneous cycle inflection detection.
|
||||
|
||||
In high-density multi-chart workspaces—such as setups operating **14 active chart windows with multi-timeframe oscillator overlays**—legacy implementations suffer from massive memory-bus saturation due to repetitive multi-megabyte array copying and hundreds of `iBarShift` queries per tick. **Version 3.10 Enterprise Edition** eliminates this latency via an inlined **Zero-Copy Architecture** and **Zero-Lag MTF Fast-Path**.
|
||||
|
||||
```text
|
||||
|
||||
┌────────────────────────────────────────────────────────────────────────┐
|
||||
│ LAGUERRE RSI OSCILLATOR SUITE │
|
||||
├──────────────────────┬────────────────────────┬────────────────────────┤
|
||||
│ Line Plot │ Color Code │ Core Role │
|
||||
├──────────────────────┼────────────────────────┼────────────────────────┤
|
||||
│ Laguerre RSI Line │ clrMediumTurquoise (W:2│ Main Momentum Curve │
|
||||
│ Signal Line │ clrLightCoral (Width:1)│ Smoothed Trigger Line │
|
||||
└──────────────────────┴────────────────────────┴────────────────────────┘
|
||||
│ LAGUERRE RSI ARCHITECTURAL EVOLUTION │
|
||||
├────────────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ LEGACY ENGINE (v3.00): │
|
||||
│ ┌──────────────────────────────────────────────────────────────┐ │
|
||||
│ │ • 4 full ArrayCopy calls on every tick (3.2 MB memory churn) │ │
|
||||
│ │ • Dynamic heap reallocations for volume buffers on each tick │ │
|
||||
│ │ • Up to 500 iBarShift API calls per tick in MTF Mode │ │
|
||||
│ │ • Memory bus saturation across multi-chart workspaces │ │
|
||||
│ └──────────────────────────────────────────────────────────────┘ │
|
||||
│ │ │
|
||||
│ ▼ OPTIMIZED │
|
||||
│ ENTERPRISE ENGINE (v3.10): │
|
||||
│ ┌──────────────────────────────────────────────────────────────┐ │
|
||||
│ │ • Zero-Copy Architecture: Direct inlined L0..L3 state reads │ │
|
||||
│ │ • Persistent Member Buffers: Zero heap allocations on ticks │ │
|
||||
│ │ • Zero-Lag MTF Fast-Path: 0 iBarShift calls on live ticks │ │
|
||||
│ │ • 1 Atomic CopyRates call per live MTF tick (-83.3% API) │ │
|
||||
│ └──────────────────────────────────────────────────────────────┘ │
|
||||
│ │
|
||||
└────────────────────────────────────────────────────────────────────────┘
|
||||
|
||||
```
|
||||
|
||||
### Key Capabilities
|
||||
|
||||
* **Time-Warped 4-Element RSI Synthesis:** Computes relative strength strictly from internal $L_0 \dots L_3$ polynomial stage differences.
|
||||
* **Harmonic Fibonacci Damping Control ($\gamma$ – Gamma):** Aligns filter sensitivity with golden ratio proportions (`0.236`, `0.382`, `0.500`, `0.618`, `0.764`, `0.882`).
|
||||
* **Integrated Signal Smoothing Engine:** Supports 8 moving average algorithms (including Volume-Weighted VWMA) for the signal trigger line.
|
||||
* **Unified 2026 MTF Framework:** Higher-timeframe Laguerre RSI curves (e.g., H1 or H4) map onto lower-timeframe execution charts (M1, M5, M15) with flat, non-warping steps via `DataSync_Tools.mqh`.
|
||||
* **Synthetic Heikin Ashi Support:** Computes smoothed momentum from filtered Heikin Ashi candles via `CLaguerreRSICalculator_HA` composition.
|
||||
- **Canonical 4-Element Time-Warped Architecture:** Eliminates standard moving average lag by synthesizing momentum directly from John Ehlers' orthogonal polynomial registers ($L_0 \dots L_3$).
|
||||
- **Zero-Copy Inlined Memory Pipeline:** Replaces legacy multi-megabyte `ArrayCopy` routines with direct inlined memory accessors, eliminating over **3.2 MB of redundant memory copying per tick**.
|
||||
- **Zero-Lag MTF Fast-Path:** Higher-timeframe curves project onto lower-timeframe execution charts as crisp, non-warping flat steps via `DataSync_Tools.mqh` with zero `iBarShift` overhead on live ticks.
|
||||
- **Full Volume-Weighted Smoothing (VWMA):** Supports 8 moving average algorithms for the signal line, allowing volume-weighted momentum confirmation.
|
||||
- **Configurable Dual-Display Architecture:** Seamlessly toggle between standalone Laguerre RSI visualization (`DISPLAY_LRSI_ONLY`) and dual-line trigger mode (`DISPLAY_LRSI_AND_SIGNAL`).
|
||||
|
||||
---
|
||||
|
||||
## 2. Mathematical Foundations & Laguerre RSI Mechanics
|
||||
## 2. Mathematical Foundations & Laguerre RSI Theory
|
||||
|
||||
```text
|
||||
|
||||
RAW PRICE (Market Highs, Lows & Closes)
|
||||
│
|
||||
▼
|
||||
┌────────────────────────────────────────────────────────┐
|
||||
│ 4-Stage Orthogonal Laguerre State Engine │
|
||||
│ L0(t) = (1 - γ)·P(t) + γ·L0(t - 1) │
|
||||
│ L1(t) = -γ·L0(t) + L0(t - 1) + γ·L1(t - 1) │
|
||||
│ L2(t) = -γ·L1(t) + L1(t - 1) + γ·L2(t - 1) │
|
||||
│ L3(t) = -γ·L2(t) + L2(t - 1) + γ·L3(t - 1) │
|
||||
└────────────────────────────┬───────────────────────────┘
|
||||
│
|
||||
▼
|
||||
CU = (L0 - L1 if > 0) + (L1 - L2 if > 0) + (L2 - L3 if > 0)
|
||||
CD = (L1 - L0 if > 0) + (L2 - L1 if > 0) + (L3 - L2 if > 0)
|
||||
│
|
||||
▼
|
||||
Laguerre RSI = [ CU / (CU + CD) ] × 100
|
||||
│
|
||||
▼
|
||||
Signal Line = MA(Laguerre RSI, Period = Signal, Type = MA_Type)
|
||||
Raw Price (P_t) ──▶ [ 4-Pole Laguerre Recursion ] ──▶ L0(t), L1(t), L2(t), L3(t)
|
||||
│
|
||||
▼
|
||||
Directional Accumulators (cu, cd)
|
||||
cu = ∑ Max( L_k - L_{k+1}, 0 )
|
||||
cd = ∑ Max( L_{k+1} - L_k, 0 )
|
||||
│
|
||||
▼
|
||||
LRSI = 100 · [ cu / (cu + cd) ]
|
||||
│
|
||||
▼
|
||||
Signal Line = MovingAverage( LRSI, SignalPeriod )
|
||||
|
||||
```
|
||||
|
||||
### 2.1. The 4-Element Laguerre State Engine
|
||||
### 2.1. Orthogonal Laguerre Polynomial Equations
|
||||
|
||||
Given input price $P_t$ and damping coefficient $\gamma = \text{InpGamma}$ ($0.0 \le \gamma \le 1.0$):
|
||||
$$L_0(t) = (1 - \gamma) P_t + \gamma L_0(t-1)$$
|
||||
$$L_1(t) = -\gamma L_0(t) + L_0(t-1) + \gamma L_1(t-1)$$
|
||||
$$L_2(t) = -\gamma L_1(t) + L_1(t-1) + \gamma L_2(t-1)$$
|
||||
$$L_3(t) = -\gamma L_2(t) + L_2(t-1) + \gamma L_3(t-1)$$
|
||||
Given input price $P_t$ (Standard or Heikin Ashi) and precomputed damping constants $\gamma = \text{InpGamma}$, $\gamma_{\text{inv}} = 1 - \gamma$, and $\gamma_{\text{neg}} = -\gamma$:
|
||||
$$L_0(t) = \gamma_{\text{inv}} \cdot P_t + \gamma \cdot L_0(t-1)$$
|
||||
$$L_1(t) = \gamma_{\text{neg}} \cdot L_0(t) + L_0(t-1) + \gamma \cdot L_1(t-1)$$
|
||||
$$L_2(t) = \gamma_{\text{neg}} \cdot L_1(t) + L_1(t-1) + \gamma \cdot L_2(t-1)$$
|
||||
$$L_3(t) = \gamma_{\text{neg}} \cdot L_2(t) + L_2(t-1) + \gamma \cdot L_3(t-1)$$
|
||||
|
||||
---
|
||||
|
||||
### 2.2. Cumulative Upward ($\text{CU}$) and Downward ($\text{CD}$) Displacements
|
||||
### 2.2. Directional Momentum Accumulators ($cu, cd$)
|
||||
|
||||
The directional displacement across adjacent stages is accumulated:
|
||||
The directional price energy across the time-warped spectrum is captured by evaluating the forward and backward differences between adjacent polynomial stages:
|
||||
$$cu_t = \max(L_0 - L_1, 0) + \max(L_1 - L_2, 0) + \max(L_2 - L_3, 0)$$
|
||||
$$cd_t = \max(L_1 - L_0, 0) + \max(L_2 - L_1, 0) + \max(L_3 - L_2, 0)$$
|
||||
|
||||
$$\text{Stage 1: } \text{if } L_0(t) \ge L_1(t) \implies \text{CU}_1 = L_0(t) - L_1(t), \quad \text{else } \text{CD}_1 = L_1(t) - L_0(t)$$
|
||||
$$\text{Stage 2: } \text{if } L_1(t) \ge L_2(t) \implies \text{CU}_2 = L_1(t) - L_2(t), \quad \text{else } \text{CD}_2 = L_2(t) - L_1(t)$$
|
||||
$$\text{Stage 3: } \text{if } L_2(t) \ge L_3(t) \implies \text{CU}_3 = L_2(t) - L_3(t), \quad \text{else } \text{CD}_3 = L_3(t) - L_2(t)$$
|
||||
### 2.3. Normalized Laguerre RSI Ratio Formulation
|
||||
|
||||
$$\text{CU}_t = \text{CU}_1 + \text{CU}_2 + \text{CU}_3$$
|
||||
$$\text{CD}_t = \text{CD}_1 + \text{CD}_2 + \text{CD}_3$$
|
||||
The final oscillator is bounded strictly between $[0.0, 100.0]$:
|
||||
$$\text{LRSI}_t = \begin{cases} 100.0 \cdot \frac{cu_t}{cu_t + cd_t}, & \text{if } cu_t + cd_t > 10^{-9} \\ \text{LRSI}_{t-1}, & \text{otherwise} \end{cases}$$
|
||||
|
||||
### 2.4. Signal Line Generation
|
||||
|
||||
When enabled (`InpDisplayMode = DISPLAY_LRSI_AND_SIGNAL`), the trigger line is smoothed via `InpSignalMAType` across $P_{\text{signal}} = \text{InpSignalPeriod}$:
|
||||
$$\text{Signal}_t = \text{MovingAverage}(\text{LRSI}, P_{\text{signal}}, \text{InpSignalMAType})_t$$
|
||||
|
||||
---
|
||||
|
||||
### 2.3. Normalized Laguerre RSI Formulation
|
||||
### 2.5. Symmetrical 5-Zone Indicator Level Matrix
|
||||
|
||||
$$\text{LRSI}_t = \begin{cases} \left( \frac{\text{CU}_t}{\text{CU}_t + \text{CD}_t} \right) \times 100, & \text{if } (\text{CU}_t + \text{CD}_t) > 10^{-9} \\ \text{LRSI}_{t-1}, & \text{if } (\text{CU}_t + \text{CD}_t) = 0 \end{cases}$$
|
||||
$$\text{Clamped Bounds: } 0.0 \le \text{LRSI}_t \le 100.0$$
|
||||
| Level Value | Level Name | Market Momentum State | Institutional Interpretation |
|
||||
| :---: | :---: | :--- | :--- |
|
||||
| **90.0** | **Extreme Overbought** | Parabolic buying climax; exhaustion imminent. | Tighten trailing stops; prepare for mean reversion. |
|
||||
| **80.0** | **Overbought Warning** | Strong bullish trend momentum active. | Bullish expansion zone; trail stops below %K/Signal. |
|
||||
| **50.0** | **Equilibrium Centerline** | Symmetrical zero-bias inflection line ($cu = cd$). | Directional pivot: $>50$ Bullish bias, $<50$ Bearish bias. |
|
||||
| **20.0** | **Oversold Warning** | Strong bearish trend momentum active. | Bearish expansion zone; trail stops above %K/Signal. |
|
||||
| **10.0** | **Extreme Oversold** | Capitulation liquidation floor; short squeeze risk. | Prepare for mean-reversion bounce; cover short positions. |
|
||||
|
||||
---
|
||||
|
||||
### 2.4. Signal Line Smoothing
|
||||
|
||||
$$\text{Signal}_t = \mathcal{MA}\left( \text{LRSI}, \text{Period} = \text{InpSignalPeriod}, \text{Type} = \text{InpSignalMAType} \right)$$
|
||||
|
||||
---
|
||||
|
||||
### 2.5. Harmonized Fibonacci Gamma ($\gamma$) Spectrum Matrix
|
||||
|
||||
| Fibonacci Gamma | Damping Depth | Phase Latency (Lag) | Target Market Regime | Equivalent EMA Benchmark | Quantitative Concept & Application |
|
||||
| :---: | :---: | :---: | :--- | :---: | :--- |
|
||||
| **`0.236`** | Ultra-Light | Near-Zero | High-Frequency Scalping / Momentum | $\approx 5\text{ EMA}$ | **Extreme Sensitivity.** Instantaneous cycle inflection and micro-reversals. |
|
||||
| **`0.382`** | Light | Very Low | Day Trading / Intraday Execution | $\approx 10\text{ EMA}$ | **Optimal Execution Baseline.** Fast cycle turns with minimal noise. |
|
||||
| **`0.500`** | Balanced | Medium-Low | Swing Trading / Volatility Pivots | $\approx 20\text{ EMA}$ | **Balanced Corridor Center.** Standard baseline for medium swing setups on M15/H1 charts. |
|
||||
| **`0.618`** | Medium-Strong | Medium | Medium-Term Trend Following | $\approx 50\text{ EMA}$ | **The Golden Ratio Anchor.** Smooth momentum transitions without whipsaws. |
|
||||
| **`0.764`** | Strong | High | Macro Cycle Filtering | $\approx 100\text{ EMA}$ | **Structural Support.** Identifies macro momentum exhaustion on H4/D1 charts. |
|
||||
| **`0.882`** | Ultra-Strong | Very High | Secular Cycle Smoothing | $\approx 200\text{ EMA}$ | **Absolute Noise Elimination.** Identifies macro secular bull/bear cycle bottoms. |
|
||||
|
||||
---
|
||||
|
||||
## 3. MQL5 Architecture & Engineering Standards
|
||||
## 3. MQL5 Architecture & Computational Benchmarking
|
||||
|
||||
```text
|
||||
|
||||
┌────────────────────────────────────────────────────────┐
|
||||
│ Laguerre_Engine.mqh │
|
||||
│ (Core DSP Math: Computes L0..L3 Orthogonal States) │
|
||||
│ (Direct Inlined Getters: GetL0..L3 in Sub-Nanosec) │
|
||||
└──────────────────────────┬─────────────────────────────┘
|
||||
│ Feeds L0..L3 State Buffers
|
||||
│ Zero-Copy Inlined Memory Access
|
||||
▼
|
||||
┌────────────────────────────────────────────────────────┐
|
||||
│ Laguerre_RSI_Calculator.mqh │
|
||||
│ (CU/CD Extraction & Normalized Laguerre RSI Engine) │
|
||||
├──────────────────────────┬─────────────────────────────┤
|
||||
│ MovingAverage_Engine │ Composition Engine │
|
||||
│ • Signal MA Smoothing │ • CLaguerreEngine_HA │
|
||||
│ • Full VWMA Support │ • Clean Pointer Safety │
|
||||
└──────────────────────────┴─────────────────────────────┘
|
||||
│ Outputs LRSI and Signal in O(1)
|
||||
│ (Persistent Volume Cache: Zero Dynamic Allocation) │
|
||||
└──────────────────────────┬─────────────────────────────┘
|
||||
│ Delivers LRSI & Signal in O(1)
|
||||
▼
|
||||
┌────────────────────────────────────────────────────────┐
|
||||
│ Laguerre_RSI_Pro.mq5 │
|
||||
│ (Unified Wrapper: Native Timeframe & MTF Engine) │
|
||||
│ (Unified Native & Zero-Lag MTF Fast-Path) │
|
||||
├──────────────────────────┬─────────────────────────────┤
|
||||
│ Direct Mode (O(1)) │ Synchronized MTF Pipeline │
|
||||
│ • Current Timeframe │ • DataSync_Tools Daemon │
|
||||
│ • 2 Output Plots │ • Staircase Flat-Force │
|
||||
│ Buffer Layer (2) │ Centralized Framework │
|
||||
│ • BufferLRSI (Plot 1) │ • DataSync_Tools.mqh │
|
||||
│ • BufferSignal (Plot 2)│ • Atomic CopyRates MTF │
|
||||
│ │ • Binary Search Snapping │
|
||||
└──────────────────────────┴─────────────────────────────┘
|
||||
|
||||
```
|
||||
|
||||
1. **Modular 3-Tier Hierarchy:** Isolates polynomial tracking (`Laguerre_Engine.mqh`) from ratio calculation (`Laguerre_RSI_Calculator.mqh`) and moving average smoothing (`MovingAverage_Engine.mqh`).
|
||||
2. **Leak-Free Pointer Protection:** Factory methods safely verify pointer validity (`CheckPointer`) before re-allocation on parameter updates.
|
||||
3. **2026 MTF Framework with Staircase Solution:**
|
||||
* Asynchronous 1-second timer daemon (`OnTimerUpdate`) ensures higher-timeframe data synchronization without UI lag.
|
||||
* Dynamic staircase anchor (`first_bar_of_forming_htf`) synchronizes all lower-timeframe sub-bars belonging to the active higher-timeframe candle.
|
||||
### Engineering Benchmark: Legacy (v3.00) vs. Enterprise (v3.10)
|
||||
|
||||
| Metric | Legacy Implementation (v3.00) | Enterprise Refactor (v3.10) | Net Optimization |
|
||||
| :--- | :---: | :---: | :---: |
|
||||
| **Memory Copied per Tick** | 3.2 MB / tick (`GetLBuffers` ArrayCopy) | **0 Bytes (Direct Inlined Getters)** | **-100% Memory Churn** |
|
||||
| **Volume Heap Allocation** | Dynamic `vol_double[]` every tick | **Persistent Member Buffer** | **Zero Allocation Pauses** |
|
||||
| **MTF Live-Tick `iBarShift`** | Up to 500 calls per tick | **0 calls on live ticks (`ArrayBsearch`)** | **Complete Zero-Lag** |
|
||||
| **MTF Data Copy Calls** | 5 separate calls per tick | **1 atomic `CopyRates` query** | **-80.0% API Overhead** |
|
||||
| **Pointer Safety** | Slow `CheckPointer()` on ticks | **Fast `if(!g_calculator)` Guard** | **Optimized Branching** |
|
||||
| **Multi-Window Scalability** | Severe UI lag on 14 charts | **Silky-smooth execution on >14 charts** | **Enterprise Certified** |
|
||||
|
||||
---
|
||||
|
||||
@@ -156,33 +155,33 @@ $$\text{Signal}_t = \mathcal{MA}\left( \text{LRSI}, \text{Period} = \text{InpSig
|
||||
|
||||
### Timeframe Settings
|
||||
|
||||
* `InpTimeframe` (*default: `PERIOD_CURRENT`*): Calculation timeframe. When set to `PERIOD_CURRENT`, it operates in native zero-lag mode. When set to a higher timeframe (e.g., `PERIOD_H1`, `PERIOD_D1`), it activates the synchronized MTF engine.
|
||||
- `InpTimeframe` (*default: `PERIOD_CURRENT`*): Calculation timeframe. Set to `PERIOD_CURRENT` for native zero-lag execution, or choose a higher timeframe (e.g., `PERIOD_M5`, `PERIOD_H1`) to activate the synchronized MTF engine.
|
||||
|
||||
### Laguerre RSI Settings
|
||||
|
||||
* `InpGamma` (*default: `0.5`*): Damping factor ($\gamma$). Controls the time-warp compression ratio ($0.0 \le \gamma \le 1.0$). Supports 3-decimal Fibonacci tuning (`0.236`, `0.382`, `0.500`, `0.618`, `0.764`, `0.882`).
|
||||
* `InpSourcePrice` (*default: `PRICE_CLOSE_STD`*): Price series source (Supports all 7 Standard and 7 Heikin Ashi modes).
|
||||
- `InpGamma` (*default: `0.5`*): Damping factor ($\gamma$). Controls the time-warp compression ratio ($0.0 \le \gamma \le 1.0$). Supports 3-decimal Fibonacci tuning (`0.236`, `0.382`, `0.500`, `0.618`, `0.764`, `0.882`).
|
||||
- `InpSourcePrice` (*default: `PRICE_CLOSE_STD`*): Applied price series source. Supports all 7 Standard and 7 Heikin Ashi modes (`PRICE_HA_CLOSE`, `PRICE_HA_TYPICAL`, etc.).
|
||||
|
||||
### Signal Line Settings
|
||||
|
||||
* `InpDisplayMode` (*default: `DISPLAY_LRSI_AND_SIGNAL`*): Display mode (`DISPLAY_LRSI_ONLY` or `DISPLAY_LRSI_AND_SIGNAL`).
|
||||
* `InpSignalPeriod` (*default: `3`*): Smoothing period for the Signal line.
|
||||
* `InpSignalMAType` (*default: `EMA`*): Smoothing method for Signal line (`SMA`, `EMA`, `SMMA`, `LWMA`, `TMA`, `DEMA`, `TEMA`, `VWMA`).
|
||||
- `InpDisplayMode` (*default: `DISPLAY_LRSI_AND_SIGNAL`*): Display mode selection (`DISPLAY_LRSI_ONLY` or `DISPLAY_LRSI_AND_SIGNAL`).
|
||||
- `InpSignalPeriod` (*default: `3`*): Lookback period for smoothing the LRSI line into the Signal line.
|
||||
- `InpSignalMAType` (*default: `EMA`*): Moving average algorithm applied to the signal line (Supports SMA, EMA, VWMA, etc.).
|
||||
|
||||
### Indicator Levels (0–100 Range)
|
||||
### Indicator Levels (0-100 Range)
|
||||
|
||||
* `InpLevelExtrHigh` (*default: `90.0`*): Extreme Overbought Climax boundary.
|
||||
* `InpLevelHigh` (*default: `80.0`*): Overbought Warning threshold.
|
||||
* `InpLevelMid` (*default: `50.0`*): Directional Equilibrium threshold.
|
||||
* `InpLevelLow` (*default: `20.0`*): Oversold Warning threshold.
|
||||
* `InpLevelExtrLow` (*default: `10.0`*): Extreme Oversold Climax boundary.
|
||||
* `InpLevelColor` (*default: `clrSilver`*): Color of horizontal level lines.
|
||||
* `InpLevelStyle` (*default: `STYLE_DOT`*): Line style of horizontal level lines.
|
||||
- `InpLevelExtrHigh` (*default: `90.0`*): Extreme Overbought threshold.
|
||||
- `InpLevelHigh` (*default: `80.0`*): Standard Overbought Warning threshold.
|
||||
- `InpLevelMid` (*default: `50.0`*): Equilibrium Baseline.
|
||||
- `InpLevelLow` (*default: `20.0`*): Standard Oversold Warning threshold.
|
||||
- `InpLevelExtrLow` (*default: `10.0`*): Extreme Oversold threshold.
|
||||
- `InpLevelColor` (*default: `clrSilver`*): Color of horizontal level lines.
|
||||
- `InpLevelStyle` (*default: `STYLE_DOT`*): Line style of horizontal level lines.
|
||||
|
||||
### Visual Settings
|
||||
|
||||
* `InpColorLRSI` (*default: `clrMediumTurquoise`*): Laguerre RSI line color (Width: 2, Solid).
|
||||
* `InpColorSignal` (*default: `clrLightCoral`*): Signal line color (Width: 1, Solid).
|
||||
- `InpColorLRSI` (*default: `clrMediumTurquoise`*): Color of the main Laguerre RSI line (Width: 2, Solid).
|
||||
- `InpColorSignal` (*default: `clrLightCoral`*): Color of the smoothed Signal line (Width: 1, Solid).
|
||||
|
||||
---
|
||||
|
||||
@@ -191,40 +190,169 @@ $$\text{Signal}_t = \mathcal{MA}\left( \text{LRSI}, \text{Period} = \text{InpSig
|
||||
```text
|
||||
|
||||
┌────────────────────────────────────────────────────────────────────────┐
|
||||
│ LAGUERRE RSI TRADING PLAYBOOKS │
|
||||
│ LAGUERRE RSI QUANTITATIVE PLAYBOOKS │
|
||||
├────────────────────────────────────────────────────────────────────────┤
|
||||
│ 1. 50-Line Equilibrium Cross: LRSI crossing > 50 = Bullish Momentum. │
|
||||
│ LRSI crossing < 50 = Bearish Momentum. │
|
||||
│ 2. Signal Crossover Trigger: LRSI crosses Signal line in direction of │
|
||||
│ higher-timeframe macro trend baseline. │
|
||||
│ 3. Deep Boundary Reversals: LRSI exiting > 90 / < 10 extreme │
|
||||
│ boundaries signals cycle exhaustion. │
|
||||
│ 1. Parabolic Climax Fade: Fade extreme climaxes when LRSI > 90 │
|
||||
│ or < 10 and crosses Signal line. │
|
||||
│ 2. Institutional Momentum Drive:Ride strong trends when LRSI holds │
|
||||
│ above 80 (Markup) or below 20 (Markdown│
|
||||
│ 3. Zero-Line Bias Inflection: Determine macro directional bias based │
|
||||
│ on whether LRSI is above/below 50.0. │
|
||||
└────────────────────────────────────────────────────────────────────────┘
|
||||
|
||||
```
|
||||
|
||||
### 5.1. The 50.0 Equilibrium Directional Shift
|
||||
### 5.1. Parabolic Climax & Capitulation Reversal Fade
|
||||
|
||||
* **Bullish Momentum Dominance:** Laguerre RSI crossing decisively **above 50.0** confirms that upward stage displacements ($\text{CU}$) are dominating downward displacements ($\text{CD}$). Favor long continuation setups.
|
||||
* **Bearish Momentum Dominance:** Laguerre RSI crossing decisively **below 50.0** confirms downward dominance.
|
||||
- **Extreme Bullish Exhaustion Fade ($> 90$):**
|
||||
- Following a rapid price expansion, Laguerre RSI surges above **90.0 (`InpLevelExtrHigh`)**.
|
||||
- LRSI rounds over and crosses strictly **below the Signal line** while holding in the $>80$ zone $\rightarrow$ Take profit on longs; initiate high-R/R counter-trend shorts targeting the 50.0 centerline.
|
||||
- **Extreme Bearish Capitulation Bounce ($< 10$):**
|
||||
- Following a panic selloff, LRSI flushes below **10.0 (`InpLevelExtrLow`)**.
|
||||
- LRSI hooks upward and crosses strictly **above the Signal line** $\rightarrow$ Cover short positions; enter long bounce trades targeting the 50.0 equilibrium.
|
||||
|
||||
### 5.2. Trend-Following Signal Line Crossovers (LRSI / Signal)
|
||||
### 5.2. Institutional Momentum Breakout Drive
|
||||
|
||||
* **Bullish Continuation Trigger:** Price is in an established uptrend, Laguerre RSI pulls back toward the 50.0 line, and crosses **above the Signal Line** $\rightarrow$ Enter Long.
|
||||
* **Bearish Continuation Trigger:** Price is in a downtrend, Laguerre RSI rallies toward 50.0, and crosses **below the Signal Line** $\rightarrow$ Enter Short.
|
||||
- **Bullish Drive Setup:**
|
||||
- In a strong breakout, LRSI penetrates strictly **above 80.0**.
|
||||
- Maintain aggressive long exposure as long as LRSI holds above 80.0. A dip below 80 indicates momentum deceleration.
|
||||
- **Bearish Markdown Setup:**
|
||||
- LRSI flushes strictly **below 20.0**.
|
||||
- Maintain short exposure as long as LRSI holds below 20.0.
|
||||
|
||||
### 5.3. Multi-Timeframe Macro Confluence
|
||||
### 5.3. Multi-Timeframe Alignment (H1/M5 MTF on M1 Execution)
|
||||
|
||||
* Attach an **H1-calculated Laguerre RSI ($\gamma=0.618$)** onto an **M5 execution chart**.
|
||||
* **Rule:** Only take M5 long breakout/pullback entries when **H1 Laguerre RSI is above 50.0 and rising**. This ensures you never trade against higher-timeframe institutional momentum.
|
||||
- Load `Laguerre_RSI_Pro` with `InpTimeframe = PERIOD_M5` onto an **M1 execution chart**.
|
||||
- The non-warping flat staircase steps represent the 5-minute directional momentum:
|
||||
- If M5 LRSI is holding above 50.0: Focus exclusively on **Long execution on M1**.
|
||||
- If M5 LRSI is holding below 50.0: Focus exclusively on **Short execution on M1**.
|
||||
|
||||
---
|
||||
|
||||
## 6. Indicator Buffer Map (For Developers & EA Integration)
|
||||
|
||||
| Buffer Index | Name | Type | Description |
|
||||
| :---: | :---: | :--- | :--- |
|
||||
| **0** | `BufferLRSI` | `INDICATOR_DATA` | Main Laguerre Relative Strength Index Line |
|
||||
| **1** | `BufferSignal` | `INDICATOR_DATA` | Smoothed Signal Trigger Line |
|
||||
### Buffer Allocation
|
||||
|
||||
*Both buffers strictly maintain non-series chronological order (`ArraySetAsSeries = false`), ensuring instant compatibility with Expert Advisors and scanner dashboards via `iCustom()`.*
|
||||
| Buffer Index | Name | Type | Visual Plot | Description |
|
||||
| :---: | :---: | :---: | :---: | :--- |
|
||||
| **0** | `BufferLRSI` | `INDICATOR_DATA` | Plot 1 (`DRAW_LINE`) | Main Laguerre RSI curve ($0.0 \dots 100.0$). |
|
||||
| **1** | `BufferSignal` | `INDICATOR_DATA` | Plot 2 (`DRAW_LINE`) | Smoothed Signal Line. |
|
||||
|
||||
*All buffers strictly maintain non-series chronological order (`ArraySetAsSeries = false`), ensuring direct compatibility with automated Expert Advisors via `iCustom()`.*
|
||||
|
||||
---
|
||||
|
||||
### MQL5 EA Integration Interface Template
|
||||
|
||||
```mql5
|
||||
//+------------------------------------------------------------------+
|
||||
//| EA_Laguerre_RSI_Interface |
|
||||
//| Copyright 2026, xxxxxxxx|
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2026, xxxxxxxx"
|
||||
#property version "1.00"
|
||||
#property strict
|
||||
|
||||
//--- Include Calculator Definitions
|
||||
#include <MyIncludes\Laguerre_RSI_Calculator.mqh>
|
||||
|
||||
//--- EA Inputs
|
||||
input group "=== Laguerre RSI Parameters ==="
|
||||
input ENUM_TIMEFRAMES InpLRSITimeframe = PERIOD_CURRENT; // Timeframe
|
||||
input double InpGamma = 0.500; // Gamma (e.g. 0.382, 0.500, 0.618)
|
||||
input ENUM_APPLIED_PRICE_HA_ALL InpPriceSource = PRICE_CLOSE_STD; // Price Source
|
||||
input ENUM_LRSI_DISPLAY_MODE InpMode = DISPLAY_LRSI_AND_SIGNAL; // Display Mode
|
||||
input int InpSignalPeriod = 3; // Signal Period
|
||||
input ENUM_MA_TYPE InpSignalType = EMA; // Signal MA Type
|
||||
|
||||
//--- Global Indicator Handle
|
||||
int g_lrsi_handle = INVALID_HANDLE;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert initialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnInit()
|
||||
{
|
||||
if(g_lrsi_handle != INVALID_HANDLE)
|
||||
IndicatorRelease(g_lrsi_handle);
|
||||
|
||||
// Instantiate handle to Laguerre_RSI_Pro via iCustom
|
||||
g_lrsi_handle = iCustom(_Symbol,
|
||||
InpLRSITimeframe,
|
||||
"Laguerre_RSI_Pro",
|
||||
InpLRSITimeframe,
|
||||
InpGamma,
|
||||
InpPriceSource,
|
||||
InpMode,
|
||||
InpSignalPeriod,
|
||||
InpSignalType);
|
||||
|
||||
if(g_lrsi_handle == INVALID_HANDLE)
|
||||
{
|
||||
PrintFormat("EA Error: Failed to create handle for Laguerre_RSI_Pro. Error: %d", GetLastError());
|
||||
return INIT_FAILED;
|
||||
}
|
||||
|
||||
Print("EA Success: Laguerre_RSI_Pro handle initialized successfully.");
|
||||
return INIT_SUCCEEDED;
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert deinitialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnDeinit(const int reason)
|
||||
{
|
||||
if(g_lrsi_handle != INVALID_HANDLE)
|
||||
{
|
||||
IndicatorRelease(g_lrsi_handle);
|
||||
g_lrsi_handle = INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert tick function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnTick()
|
||||
{
|
||||
// Query completed closed candle (Shift = 1) and previous candle (Shift = 2) for LRSI and Signal
|
||||
double lrsi_vals[2], signal_vals[2];
|
||||
ArraySetAsSeries(lrsi_vals, true); // Index 0 = Shift 1, Index 1 = Shift 2
|
||||
ArraySetAsSeries(signal_vals, true);
|
||||
|
||||
if(CopyBuffer(g_lrsi_handle, 0, 1, 2, lrsi_vals) < 2 ||
|
||||
CopyBuffer(g_lrsi_handle, 1, 1, 2, signal_vals) < 2)
|
||||
{
|
||||
return; // Data synchronizing
|
||||
}
|
||||
|
||||
double lrsi_bar1 = lrsi_vals[0];
|
||||
double signal_bar1 = signal_vals[0];
|
||||
|
||||
// Quantitative Momentum Regimes
|
||||
bool is_climax_high = (lrsi_bar1 >= 90.0);
|
||||
bool is_climax_low = (lrsi_bar1 <= 10.0);
|
||||
bool is_overbought = (lrsi_bar1 >= 80.0);
|
||||
bool is_oversold = (lrsi_bar1 <= 20.0);
|
||||
bool is_bullish_bias = (lrsi_bar1 > 50.0);
|
||||
bool is_bearish_bias = (lrsi_bar1 < 50.0);
|
||||
|
||||
// Momentum Crossover Signals
|
||||
bool signal_crossed_up = (lrsi_vals[1] <= signal_vals[1] && lrsi_vals[0] > signal_vals[0]);
|
||||
bool signal_crossed_down = (lrsi_vals[1] >= signal_vals[1] && lrsi_vals[0] < signal_vals[0]);
|
||||
|
||||
// Telemetry Output
|
||||
Comment(StringFormat("Laguerre RSI Telemetry [Bar 1]:\n"
|
||||
"LRSI: %.2f | Signal: %.2f\n"
|
||||
"Bias: %s | State: %s\n"
|
||||
"Crossover Signals -> Buy: %s | Sell: %s",
|
||||
lrsi_bar1, signal_bar1,
|
||||
is_bullish_bias ? "BULLISH (> 50.0)" : (is_bearish_bias ? "BEARISH (< 50.0)" : "EQUILIBRIUM"),
|
||||
is_climax_high ? "EXTREME CLIMAX (>= 90)" :
|
||||
(is_climax_low ? "EXTREME CAPITULATION (<= 10)" :
|
||||
(is_overbought ? "OVERBOUGHT (>= 80)" :
|
||||
(is_oversold ? "OVERSOLD (<= 20)" : "NORMAL RANGE"))),
|
||||
(signal_crossed_up && is_bullish_bias) ? "TRIGGERED (Bullish Cross)" : "NO",
|
||||
(signal_crossed_down && is_bearish_bias) ? "TRIGGERED (Bearish Cross)" : "NO"));
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user