From e3396d81f0154bd177dcce1c530d7a46b36800d2 Mon Sep 17 00:00:00 2001 From: Toh4iem9 Date: Sat, 29 Nov 2025 13:40:22 +0100 Subject: [PATCH] refactor: Optimized for incremental calculation --- .../4_Channels_and_Bands/Ehlers_Bands_Pro.mq5 | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Indicators/MyIndicators/Authors/Ehlers/4_Channels_and_Bands/Ehlers_Bands_Pro.mq5 b/Indicators/MyIndicators/Authors/Ehlers/4_Channels_and_Bands/Ehlers_Bands_Pro.mq5 index 7d1f902..bdb8451 100644 --- a/Indicators/MyIndicators/Authors/Ehlers/4_Channels_and_Bands/Ehlers_Bands_Pro.mq5 +++ b/Indicators/MyIndicators/Authors/Ehlers/4_Channels_and_Bands/Ehlers_Bands_Pro.mq5 @@ -1,10 +1,9 @@ //+------------------------------------------------------------------+ //| Ehlers_Bands_Pro.mq5 | //| Copyright 2025, xxxxxxxx| -//| | //+------------------------------------------------------------------+ #property copyright "Copyright 2025, xxxxxxxx" -#property version "1.00" +#property version "1.10" // Optimized for incremental calculation #property description "Ehlers Bands with a selectable smoother (SuperSmoother or UltimateSmoother)." #property indicator_chart_window @@ -83,7 +82,18 @@ void OnDeinit(const int reason) } //+------------------------------------------------------------------+ -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&[]) +//| Custom indicator calculation function | +//+------------------------------------------------------------------+ +int OnCalculate(const int rates_total, + const int prev_calculated, // <--- Now used! + const datetime &time[], + const double &open[], + const double &high[], + const double &low[], + const double &close[], + const long &tick_volume[], + const long &volume[], + const int &spread[]) { if(CheckPointer(g_calculator) == POINTER_INVALID) return 0; @@ -94,7 +104,9 @@ int OnCalculate(const int rates_total, const int, const datetime&[], const doubl else price_type = (ENUM_APPLIED_PRICE)InpSourcePrice; - g_calculator.Calculate(rates_total, price_type, open, high, low, close, BufferUpper, BufferLower, BufferMiddle); +//--- Delegate calculation with prev_calculated optimization + g_calculator.Calculate(rates_total, prev_calculated, price_type, open, high, low, close, BufferUpper, BufferLower, BufferMiddle); + return(rates_total); } //+------------------------------------------------------------------+