From 2c0ed6b120e27264dcca8edfeb726d48afc39b74 Mon Sep 17 00:00:00 2001 From: Toh4iem9 Date: Sat, 6 Dec 2025 20:44:44 +0100 Subject: [PATCH] refactor: Optimized for incremental calculation --- .../Authors/Ehlers/3_Adaptive_MAs/MAMA_Pro.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Indicators/MyIndicators/Authors/Ehlers/3_Adaptive_MAs/MAMA_Pro.md b/Indicators/MyIndicators/Authors/Ehlers/3_Adaptive_MAs/MAMA_Pro.md index 3c8d8ad..c77d784 100644 --- a/Indicators/MyIndicators/Authors/Ehlers/3_Adaptive_MAs/MAMA_Pro.md +++ b/Indicators/MyIndicators/Authors/Ehlers/3_Adaptive_MAs/MAMA_Pro.md @@ -34,8 +34,12 @@ The calculation is a complex, multi-stage digital signal processing pipeline: ## 3. MQL5 Implementation Details * **Self-Contained Calculator (`MAMA_Calculator.mqh`):** The entire complex, multi-stage, and highly state-dependent calculation is encapsulated within a dedicated, reusable calculator class. -* **Heikin Ashi Integration:** An inherited `_HA` class allows the calculation to be performed seamlessly on smoothed Heikin Ashi data, leveraging our optimized `HeikinAshi_Tools` library. -* **Stability via Full Recalculation:** The MAMA algorithm is one of the most state-dependent filters in technical analysis. To ensure absolute stability and prevent desynchronization errors (especially with the phase measurement), the indicator employs a **full recalculation** on every `OnCalculate` call. This is the only robust method for this type of complex DSP filter. +* **Optimized Incremental Calculation:** + Unlike basic implementations that recalculate the entire history on every tick, this indicator employs an intelligent incremental algorithm. + * It utilizes the `prev_calculated` state to determine the exact starting point for updates. + * **Persistent State:** The internal buffers for the Homodyne Discriminator (`m_I1_buf`, `m_Q1_buf`, etc.) and the phase measurement persist their state between ticks. This allows the complex DSP pipeline to continue seamlessly from the last known values without re-processing the entire history. + * This results in **O(1) complexity** per tick, ensuring instant updates and zero lag, even on charts with extensive history. +* **Heikin Ashi Integration:** An inherited `_HA` class allows the calculation to be performed seamlessly on smoothed Heikin Ashi data, leveraging the same optimized engine. ## 4. Parameters