From 97f55e82bebb238724ea88ad4da1e91f93f6deee Mon Sep 17 00:00:00 2001 From: Toh4iem9 Date: Sat, 29 Nov 2025 11:55:09 +0100 Subject: [PATCH] refactor: Optimized for incremental MTF calculation --- .../Ehlers/1_Smoothers/Ehlers_Smoother_MTF_Pro.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Indicators/MyIndicators/Authors/Ehlers/1_Smoothers/Ehlers_Smoother_MTF_Pro.md b/Indicators/MyIndicators/Authors/Ehlers/1_Smoothers/Ehlers_Smoother_MTF_Pro.md index 8a649ec..5d3ee04 100644 --- a/Indicators/MyIndicators/Authors/Ehlers/1_Smoothers/Ehlers_Smoother_MTF_Pro.md +++ b/Indicators/MyIndicators/Authors/Ehlers/1_Smoothers/Ehlers_Smoother_MTF_Pro.md @@ -1,4 +1,4 @@ -# Ehlers Smoother MTF Professional +# Ehlers Smoother MTF Pro ## 1. Summary (Introduction) @@ -30,11 +30,16 @@ The underlying calculations are identical to the standard Ehlers Smoothers, whic * **Stable Calculation Engine (`Ehlers_Smoother_Calculator.mqh`):** The indicator reuses the exact same, proven calculation engine as the standard `Ehlers_Smoother_Pro`. Crucially, this engine implements **correct state management** for the recursive filter's internal variables (`m_f1`, `m_f2`), ensuring a stable and accurate output. -* **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 `Ehlers_Smoother_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 (`BufferFilter_HTF_Internal`) is maintained globally, preserving the recursive state of the IIR filter 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 highly sensitive recursive filters like Ehlers'. +* **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 `Ehlers_Smoother_Pro`, calculating directly on the current chart's data for maximum efficiency. ## 4. Parameters