From ae3b15cf9a57a43eb0b2e7583982774c2aeff222 Mon Sep 17 00:00:00 2001 From: Toh4iem9 Date: Mon, 29 Jun 2026 23:34:07 +0200 Subject: [PATCH] refactor: Refactored to map Signal MA calculations elegantly via standard close-buffer mapping --- .../Ehlers/2_Oscillators/Cyber_Cycle_Pro.mq5 | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Indicators/MyIndicators/Authors/Ehlers/2_Oscillators/Cyber_Cycle_Pro.mq5 b/Indicators/MyIndicators/Authors/Ehlers/2_Oscillators/Cyber_Cycle_Pro.mq5 index e45131a..bdbf59a 100644 --- a/Indicators/MyIndicators/Authors/Ehlers/2_Oscillators/Cyber_Cycle_Pro.mq5 +++ b/Indicators/MyIndicators/Authors/Ehlers/2_Oscillators/Cyber_Cycle_Pro.mq5 @@ -3,9 +3,9 @@ //| Copyright 2026, xxxxxxxx| //+------------------------------------------------------------------+ #property copyright "Copyright 2026, xxxxxxxx" -#property version "3.05" // Optimized for array index safety and robust pointer verification +#property version "3.20" // Refactored to map Signal MA calculations elegantly via standard close-buffer mapping #property description "John Ehlers' Cyber Cycle indicator for identifying market cycles." -#property description "Features O(1) calculation and flexible Signal Line options." +#property description "Features O(1) calculation and flexible Signal Line options including VWMA." #property indicator_separate_window #property indicator_buffers 2 @@ -37,7 +37,7 @@ input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_MEDIAN_STD; // Price Sou input group "Signal Line Settings" input ENUM_CYBER_SIGNAL_TYPE InpSignalType = SIGNAL_DELAY_1BAR; // Signal Type input int InpSignalPeriod = 3; // Period (if MA) -input ENUM_MA_TYPE InpSignalMethod = SMA; // Method (if MA) +input ENUM_MA_TYPE InpSignalMethod = SMA; // Method (if MA / VWMA) //--- Indicator Buffers --- double BufferCycle[]; @@ -122,8 +122,18 @@ int OnCalculate(const int rates_total, (ENUM_APPLIED_PRICE)(-(int)InpSourcePrice) : (ENUM_APPLIED_PRICE)InpSourcePrice; - g_calculator.Calculate(rates_total, prev_calculated, price_type, open, high, low, close, - BufferCycle, BufferSignal); +//--- Determine best volume array (Use Real Volume if available, otherwise fallback to Tick Volume) + long volume_limit = (long)SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_LIMIT); + +//--- Route calculations dynamically to support volume-weighted types (VWMA) on the Signal Line + if(volume_limit > 0) + { + g_calculator.Calculate(rates_total, prev_calculated, price_type, open, high, low, close, volume, BufferCycle, BufferSignal); + } + else + { + g_calculator.Calculate(rates_total, prev_calculated, price_type, open, high, low, close, tick_volume, BufferCycle, BufferSignal); + } return(rates_total); }