From a9b1bc25d309f99786e65829b4722576c2765e4b Mon Sep 17 00:00:00 2001 From: Toh4iem9 Date: Mon, 5 Jan 2026 16:15:15 +0100 Subject: [PATCH] docs(indicators): Unified MTF Engine Pattern --- .../MyIndicators/MovingAverage_MTF_Pro.md | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/Indicators/MyIndicators/MovingAverage_MTF_Pro.md b/Indicators/MyIndicators/MovingAverage_MTF_Pro.md index fc91bff..ef7eaf4 100644 --- a/Indicators/MyIndicators/MovingAverage_MTF_Pro.md +++ b/Indicators/MyIndicators/MovingAverage_MTF_Pro.md @@ -2,47 +2,50 @@ ## 1. Summary (Introduction) -The `MovingAverage_MTF_Pro` is a versatile multi-timeframe (MTF) version of our universal moving average indicator. It allows a trader to calculate one of the four fundamental moving average types (SMA, EMA, SMMA, LWMA) on a **higher, user-selected timeframe** and project it onto the current, lower-timeframe chart. +The `MovingAverage_MTF_Pro` is a versatile multi-timeframe (MTF) version of our universal moving average indicator. It allows a trader to calculate any of the supported moving average types on a **higher, user-selected timeframe** and project it onto the current, lower-timeframe chart. This provides a clear, smoothed-out view of the underlying trend from a broader perspective without needing to switch charts. ## 2. Mathematical Foundations and Calculation Logic -### Core MA Types +### Supported MA Types + +The indicator leverages the unified `MovingAverage_Engine`, supporting a wide range of algorithms: * **SMA:** Simple Moving Average. * **EMA:** Exponential Moving Average. * **SMMA:** Smoothed Moving Average (Wilder's). * **LWMA:** Linear Weighted Moving Average. +* **DEMA:** Double Exponential Moving Average (Faster, less lag). +* **TEMA:** Triple Exponential Moving Average (Even faster). +* **TMA:** Triangular Moving Average (Double-smoothed SMA). ### MTF Calculation Steps 1. **Fetch Data:** Retrieves OHLC data for the selected higher timeframe. -2. **Calculate:** Performs the recursive or standard calculation on the higher timeframe data. -3. **Map:** Projects the values to the current chart, creating a "step-like" visual representation. +2. **Calculate:** Performs the recursive or standard calculation on the higher timeframe data using the unified engine. +3. **Map:** Projects the values to the current chart using precise time-based alignment (`iBarShift`), creating a "step-like" visual representation that accurately reflects when the higher timeframe bar closed. ## 3. MQL5 Implementation Details -* **Self-Contained:** No `iCustom` dependencies. Uses direct `Copy...` functions for stability. -* **Universal Engine (`MovingAverage_Engine.mqh`):** Reuses the core logic from the standard suite for consistency. - +* **Self-Contained:** No `iCustom` dependencies. Uses direct `Copy...` functions for maximum stability and speed. +* **Universal Engine (`MovingAverage_Engine.mqh`):** Reuses the core logic from the standard suite, ensuring mathematical consistency across all indicators. * **Optimized Incremental Calculation (O(1)):** This indicator is engineered for performance: * **HTF State Tracking:** Tracks `htf_prev_calculated` to avoid redundant math on the higher timeframe. - * **Persistent State:** Preserves the recursive state of EMAs and SMMAs between ticks. + * **Persistent State:** Preserves the recursive state of EMAs, DEMAs, etc., between ticks. * **Smart Mapping:** The projection loop handles index alignment precisely and only updates changed bars. - * **Dual-Mode Logic:** Automatically switches between MTF mode (projection) and Standard mode (direct calculation) based on the timeframe selection. ## 4. Parameters -* **Upper Timeframe (`InpUpperTimeframe`):** The calculation timeframe. -* **Period (`InpPeriod`):** The lookback period. -* **MA Type (`InpMAType`):** SMA, EMA, SMMA, or LWMA. -* **Applied Price (`InpSourcePrice`):** Standard or Heikin Ashi price sources. +* **Upper Timeframe (`InpUpperTimeframe`):** The calculation timeframe (e.g., H1, H4, D1). Must be greater than or equal to the current chart timeframe. +* **Period (`InpPeriod`):** The lookback period for the moving average. +* **MA Type (`InpMAType`):** Selects the calculation algorithm (SMA, EMA, DEMA, etc.). +* **Applied Price (`InpSourcePrice`):** Standard (Close, Open, etc.) or Heikin Ashi price sources. ## 5. Usage and Interpretation * **Trend Direction:** A rising MTF MA indicates a bullish higher-timeframe trend; falling indicates bearish. -* **Pullbacks:** In an uptrend, a pullback to the MTF MA often represents a high-value buying opportunity (dynamic support). -* **Crossovers:** Price crossing the MTF MA can signal a potential reversal in the major trend. +* **Dynamic Support/Resistance:** In an uptrend, a pullback to the MTF MA often represents a high-value buying opportunity (dynamic support). +* **Trend Filter:** Use the slope or position of the MTF MA to filter signals from faster indicators on the current chart (e.g., only buy if price is above the H4 EMA).