refactor(indicators): Optimized for incremental calculation

This commit is contained in:
Toh4iem9
2026-01-04 10:33:45 +01:00
parent 48ca050e1e
commit 0f72eefba4
@@ -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 <MyIncludes\ZeroLag_EMA_Calculator.mqh>
@@ -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);
}
//+------------------------------------------------------------------+