refactor: Optimized for incremental calculation

This commit is contained in:
Toh4iem9
2025-11-30 14:04:38 +01:00
parent 0e63de36f9
commit b10c0192f3
+7 -3
View File
@@ -1,4 +1,4 @@
# Slow Stochastic RSI Professional
# Slow Stochastic RSI Pro
## 1. Summary (Introduction)
@@ -33,14 +33,18 @@ Our MQL5 implementation follows a modern, component-based, object-oriented desig
* **Component-Based Design:** The StochRSI calculator (`StochRSI_Slow_Calculator.mqh`) does not recalculate the RSI internally. Instead, it **reuses** our existing, standalone `RSI_Pro_Calculator.mqh` module. This eliminates code duplication and ensures that both the RSI and StochRSI indicators are always based on the exact same, robust RSI calculation logic.
* **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 (like `m_rsi_buffer` and `m_raw_k`) persist their state between ticks. This allows recursive smoothing methods (like EMA and SMMA) to continue seamlessly from the last known value 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.
* **Object-Oriented Logic:**
* The `CStochRSI_Slow_Calculator` contains a pointer to an `CRSIProCalculator` object.
* The Heikin Ashi version (`CStochRSI_Slow_Calculator_HA`) is achieved simply by instructing the main calculator to instantiate the Heikin Ashi version of the RSI module (`CRSIProCalculator_HA`).
* **Full MA Type Support:** The calculator contains a complete, robust implementation for all standard MQL5 MA types (SMA, EMA, SMMA, LWMA) for both the "Slowing" and the "%D" smoothing steps.
* **Stability via Full Recalculation:** We employ a "brute-force" full recalculation within `OnCalculate` for maximum stability.
## 4. Parameters
* **RSI Period (`InpRSIPeriod`):** The lookback period for the underlying RSI.