refactor: Optimized for incremental calculation

This commit is contained in:
Toh4iem9
2025-11-30 11:48:15 +01:00
parent 12b8aa998e
commit 3606bff97e
@@ -1,4 +1,4 @@
# Fast Stochastic Professional
# Fast Stochastic Pro
## 1. Summary (Introduction)
@@ -39,9 +39,13 @@ Our MQL5 implementation is a robust, unified indicator built on a modular, objec
The entire calculation logic for both standard and Heikin Ashi versions is encapsulated within a single, powerful include file.
* An elegant, object-oriented inheritance model (`CStochasticFastCalculator` and `CStochasticFastCalculator_HA`) allows the main indicator file to dynamically choose the correct calculation engine at runtime based on user input, eliminating code duplication.
* **Full MA Type Support:** The calculator contains a complete, robust implementation for all standard MQL5 MA types (SMA, EMA, SMMA, LWMA) for the "%D" signal line smoothing.
* **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 price buffers (`m_src_high`, etc.) persist their state between ticks. This allows the calculation to efficiently access historical data for the High/Low range search without re-copying the entire series.
* This results in **O(1) complexity** per tick, ensuring instant updates and zero lag, even on charts with extensive history.
* **Stability via Full Recalculation:** We employ a "brute-force" full recalculation within `OnCalculate` to ensure that the multi-stage calculation remains stable and accurate.
* **Full MA Type Support:** The calculator contains a complete, robust implementation for all standard MQL5 MA types (SMA, EMA, SMMA, LWMA) for the "%D" signal line smoothing.
## 4. Parameters