From 8af52ff709638f2157870982e06626dc86ccfc44 Mon Sep 17 00:00:00 2001 From: Toh4iem9 Date: Sat, 3 Jan 2026 09:27:29 +0100 Subject: [PATCH] refactor(indicators): Optimized for incremental calculation --- .../Authors/Kaufman/Polynomial_Regression_Slope_Pro.mq5 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Indicators/MyIndicators/Authors/Kaufman/Polynomial_Regression_Slope_Pro.mq5 b/Indicators/MyIndicators/Authors/Kaufman/Polynomial_Regression_Slope_Pro.mq5 index c1f1c6b..a9316d5 100644 --- a/Indicators/MyIndicators/Authors/Kaufman/Polynomial_Regression_Slope_Pro.mq5 +++ b/Indicators/MyIndicators/Authors/Kaufman/Polynomial_Regression_Slope_Pro.mq5 @@ -1,10 +1,9 @@ //+------------------------------------------------------------------+ //| Polynomial_Regression_Slope_Pro.mq5 | //| Copyright 2025, xxxxxxxx| -//| | //+------------------------------------------------------------------+ #property copyright "Copyright 2025, xxxxxxxx" -#property version "1.00" +#property version "2.00" // Optimized for incremental calculation #property description "Calculates the slope (1st derivative) of a moving Polynomial Regression." #property description "Functions as a smooth, zero-lag momentum oscillator." @@ -60,12 +59,14 @@ int OnInit() void OnDeinit(const int reason) { if(CheckPointer(g_calculator) != POINTER_INVALID) delete g_calculator; } //+------------------------------------------------------------------+ -int OnCalculate(const int rates_total, const int, const datetime&[], const double &open[], const double &high[], const double &low[], const double &close[], const long&[], const long&[], const int&[]) +int OnCalculate(const int rates_total, const int prev_calculated, const datetime&[], const double &open[], const double &high[], const double &low[], const double &close[], const long&[], const long&[], const int&[]) { if(CheckPointer(g_calculator) == POINTER_INVALID) return 0; ENUM_APPLIED_PRICE price_type = (InpSourcePrice <= PRICE_HA_CLOSE) ? (ENUM_APPLIED_PRICE)(-(int)InpSourcePrice) : (ENUM_APPLIED_PRICE)InpSourcePrice; - g_calculator.Calculate(rates_total, price_type, open, high, low, close, BufferSlope); + + g_calculator.Calculate(rates_total, prev_calculated, price_type, open, high, low, close, BufferSlope); + return(rates_total); } //+------------------------------------------------------------------+