From c5a302f448eb4980d4f349a62f4ef8272d90aad8 Mon Sep 17 00:00:00 2001 From: Toh4iem9 Date: Tue, 30 Jun 2026 14:22:21 +0200 Subject: [PATCH] refactor: Upgraded with 3-digit Gamma precision and strict chronological state safety --- .../Laguerre_Stoch_Fast_MTF_Pro.mq5 | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Indicators/MyIndicators/Authors/Ehlers/2_Oscillators/Laguerre_Stoch_Fast_MTF_Pro.mq5 b/Indicators/MyIndicators/Authors/Ehlers/2_Oscillators/Laguerre_Stoch_Fast_MTF_Pro.mq5 index 97b18db..3dc2a6e 100644 --- a/Indicators/MyIndicators/Authors/Ehlers/2_Oscillators/Laguerre_Stoch_Fast_MTF_Pro.mq5 +++ b/Indicators/MyIndicators/Authors/Ehlers/2_Oscillators/Laguerre_Stoch_Fast_MTF_Pro.mq5 @@ -3,7 +3,7 @@ //| Copyright 2026, xxxxxxxx| //+------------------------------------------------------------------+ #property copyright "Copyright 2026, xxxxxxxx" -#property version "1.00" // Dynamic Multi-Timeframe Laguerre Stochastic Fast with flat-force step-alignment +#property version "1.10" // Upgraded with 3-digit Gamma precision and strict chronological state safety #property description "Multi-Timeframe (MTF) John Ehlers' Laguerre Stochastic Fast." #property description "Displays HTF Laguerre Stochastic Fast and Signal Line cleanly without live-bar warping." @@ -42,7 +42,7 @@ input group "Timeframe Settings" input ENUM_TIMEFRAMES InpUpperTimeframe = PERIOD_H1; // Target Higher Timeframe input group "Laguerre Settings" -input double InpGamma = 0.7; // Gamma (0.0 - 1.0) +input double InpGamma = 0.7; // Gamma (0.0 - 1.0, e.g. 0.236, 0.382) input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD; // Price Source input group "Signal Line Settings" @@ -126,10 +126,10 @@ int OnInit() return(INIT_FAILED); } -//--- 4. Set Shortname +//--- 4. Set Shortname - Updated format string to %.3f to support exact Fibonacci decimals string type = (InpSourcePrice <= PRICE_HA_CLOSE) ? " HA" : ""; string tf_str = g_is_mtf_mode ? (" " + EnumToString(g_calc_timeframe)) : ""; - IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("Laguerre Stoch Fast%s%s(%.2f)", type, tf_str, InpGamma)); + IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("Laguerre Stoch Fast%s%s(%.3f)", type, tf_str, InpGamma)); // Draw begin logic int draw_begin = 2; @@ -174,6 +174,16 @@ int OnCalculate(const int rates_total, if(rates_total < 2) return(0); + if(CheckPointer(g_calculator) == POINTER_INVALID) + return(0); + +//--- Force strict chronological indexing for state-safety on input price arrays + ArraySetAsSeries(time, false); + ArraySetAsSeries(open, false); + ArraySetAsSeries(high, false); + ArraySetAsSeries(low, false); + ArraySetAsSeries(close, false); + ENUM_APPLIED_PRICE price_type = (InpSourcePrice <= PRICE_HA_CLOSE) ? (ENUM_APPLIED_PRICE)(-(int)InpSourcePrice) : (ENUM_APPLIED_PRICE)InpSourcePrice; @@ -237,6 +247,14 @@ int OnCalculate(const int rates_total, ArrayResize(h_res_stoch, g_htf_count); ArrayResize(h_res_sig, g_htf_count); + // Force chronological array alignment on HTF caches after resize + ArraySetAsSeries(h_time, false); + ArraySetAsSeries(h_open, false); + ArraySetAsSeries(h_high, false); + ArraySetAsSeries(h_low, false); + ArraySetAsSeries(h_close, false); + ArraySetAsSeries(h_vol, false); + if(CopyTime(_Symbol, g_calc_timeframe, 0, g_htf_count, h_time) != g_htf_count || CopyOpen(_Symbol, g_calc_timeframe, 0, g_htf_count, h_open) != g_htf_count || CopyHigh(_Symbol, g_calc_timeframe, 0, g_htf_count, h_high) != g_htf_count || @@ -367,4 +385,3 @@ void OnTimer() } } //+------------------------------------------------------------------+ -//+------------------------------------------------------------------+