From 797f125db37202d5bd5bb52c8debabd35b3b0613 Mon Sep 17 00:00:00 2001 From: Toh4iem9 Date: Tue, 16 Dec 2025 15:24:23 +0100 Subject: [PATCH] refactor: Optimized for incremental calculation --- Indicators/MyIndicators/GannHiLo_Pro.mq5 | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Indicators/MyIndicators/GannHiLo_Pro.mq5 b/Indicators/MyIndicators/GannHiLo_Pro.mq5 index 34d0de8..1765695 100644 --- a/Indicators/MyIndicators/GannHiLo_Pro.mq5 +++ b/Indicators/MyIndicators/GannHiLo_Pro.mq5 @@ -1,11 +1,9 @@ //+------------------------------------------------------------------+ //| Gann_HiLo_Pro.mq5| //| Copyright 2025, xxxxxxxx| -//| | //+------------------------------------------------------------------+ #property copyright "Copyright 2025, xxxxxxxx" -#property link "" -#property version "3.01" // Corrected calculator call signature +#property version "3.10" // Optimized for incremental calculation #property description "Professional Gann HiLo Activator with selectable MA and" #property description "candle source (Standard or Heikin Ashi)." @@ -92,10 +90,10 @@ void OnDeinit(const int reason) } //+------------------------------------------------------------------+ -//| Custom indicator calculation function. | +//| Custom indicator calculation function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, - const int prev_calculated, + const int prev_calculated, // <--- Now used! const datetime &time[], const double &open[], const double &high[], @@ -105,15 +103,13 @@ int OnCalculate(const int rates_total, const long &volume[], const int &spread[]) { -//--- Ensure the calculator object is valid if(CheckPointer(g_calculator) == POINTER_INVALID) return 0; -//--- Delegate the entire calculation to our calculator object -//--- CORRECTED: Pass the 'open' array for HA calculation - g_calculator.Calculate(rates_total, open, high, low, close, BufferGannHiLo, BufferColor); +//--- Delegate calculation with prev_calculated optimization +// Note: We pass 'open' array even though base calc doesn't use it, but HA calc does. + g_calculator.Calculate(rates_total, prev_calculated, open, high, low, close, BufferGannHiLo, BufferColor); -//--- Return rates_total for a full recalculation, ensuring stability return(rates_total); } //+------------------------------------------------------------------+