mirror of
https://github.com/softwaredevelop/mql5.git
synced 2026-08-01 22:57:44 +00:00
refactor: Optimized for incremental MTF calculation
This commit is contained in:
@@ -34,11 +34,16 @@ The underlying calculation is identical to the standard VIDYA. It is a modified
|
||||
|
||||
* **Modular Calculation Engine (`VIDYA_Calculator.mqh`):** The indicator reuses the exact same, proven calculation engine as the standard `VIDYA_Pro`. This ensures mathematical consistency and leverages our modular design principles.
|
||||
|
||||
* **Dual-Mode Logic:** The `OnCalculate` function contains a smart branching logic.
|
||||
* If a higher timeframe is selected, it performs the full MTF data fetching and projection process.
|
||||
* If the current timeframe is selected, it bypasses the MTF logic and functions identically to the standard `VIDYA_Pro`, calculating directly on the current chart's data for maximum efficiency.
|
||||
* **Optimized Incremental Calculation:**
|
||||
Unlike basic MTF indicators that download and recalculate the entire higher-timeframe history on every tick, this indicator employs a sophisticated incremental algorithm.
|
||||
* **HTF State Tracking:** It tracks the calculation state of the higher timeframe separately (`htf_prev_calculated`).
|
||||
* **Persistent Buffers:** The internal buffer for the higher timeframe (`BufferVIDYA_HTF_Internal`) is maintained globally, preserving the recursive state of the VIDYA algorithm between ticks.
|
||||
* **Efficient Mapping:** The projection loop only updates the bars corresponding to the new data, drastically reducing CPU usage.
|
||||
* This results in **O(1) complexity** per tick, ensuring the indicator remains lightweight even when running on multiple charts simultaneously.
|
||||
|
||||
* **Stability via Full Recalculation:** We employ a full recalculation for both modes, which is the most reliable method for a recursive indicator like VIDYA.
|
||||
* **Dual-Mode Logic:** The `OnCalculate` function contains a smart branching logic.
|
||||
* If a higher timeframe is selected, it performs the optimized MTF data fetching and projection process.
|
||||
* If the current timeframe is selected, it bypasses the MTF logic and functions identically to the standard `VIDYA_Pro`, calculating directly on the current chart's data for maximum efficiency.
|
||||
|
||||
## 4. Parameters
|
||||
|
||||
|
||||
Reference in New Issue
Block a user