From 0f72eefba40b102f6acd9ffe8c309f1b88082cab Mon Sep 17 00:00:00 2001 From: Toh4iem9 Date: Sun, 4 Jan 2026 10:33:45 +0100 Subject: [PATCH] refactor(indicators): Optimized for incremental calculation --- .../Authors/Ehlers/1_Smoothers/ZeroLag_EMA_Pro.mq5 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Indicators/MyIndicators/Authors/Ehlers/1_Smoothers/ZeroLag_EMA_Pro.mq5 b/Indicators/MyIndicators/Authors/Ehlers/1_Smoothers/ZeroLag_EMA_Pro.mq5 index 5290d82..fac3039 100644 --- a/Indicators/MyIndicators/Authors/Ehlers/1_Smoothers/ZeroLag_EMA_Pro.mq5 +++ b/Indicators/MyIndicators/Authors/Ehlers/1_Smoothers/ZeroLag_EMA_Pro.mq5 @@ -1,10 +1,9 @@ //+------------------------------------------------------------------+ //| ZeroLag_EMA_Pro.mq5 | //| Copyright 2025, xxxxxxxx| -//| | //+------------------------------------------------------------------+ #property copyright "Copyright 2025, xxxxxxxx" -#property version "2.00" // Added Ehlers' optimized gain (Error Correcting) mode +#property version "2.00" // Optimized for incremental calculation #property description "Zero-Lag Exponential Moving Average (ZLEMA). Supports standard" #property description "and Ehlers' optimized gain (Error Correcting) modes." @@ -15,7 +14,7 @@ #property indicator_type1 DRAW_LINE #property indicator_color1 clrMediumTurquoise #property indicator_style1 STYLE_SOLID -#property indicator_width1 1 +#property indicator_width1 2 #include @@ -69,7 +68,7 @@ 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&[]) +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; @@ -80,7 +79,7 @@ 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, BufferZLEMA); + g_calculator.Calculate(rates_total, prev_calculated, price_type, open, high, low, close, BufferZLEMA); return(rates_total); } //+------------------------------------------------------------------+