From d13929ead3633a8af11e3756fad67c0d4c5a0938 Mon Sep 17 00:00:00 2001 From: Toh4iem9 Date: Fri, 26 Jun 2026 13:43:47 +0200 Subject: [PATCH] refactor: Upgraded with dynamic volume routing to support VWMA Slowing/Signals --- Indicators/MyIndicators/DMIStochastic_Pro.mq5 | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Indicators/MyIndicators/DMIStochastic_Pro.mq5 b/Indicators/MyIndicators/DMIStochastic_Pro.mq5 index 8a129bd..200529f 100644 --- a/Indicators/MyIndicators/DMIStochastic_Pro.mq5 +++ b/Indicators/MyIndicators/DMIStochastic_Pro.mq5 @@ -1,9 +1,9 @@ //+------------------------------------------------------------------+ -//| DMIStochastic_Pro.mq5 | +//| DMIStochastic_Pro.mq5 | //| Copyright 2026, xxxxxxxx| //+------------------------------------------------------------------+ #property copyright "Copyright 2026, xxxxxxxx" -#property version "2.20" // Added fixed digits precision +#property version "2.30" // Upgraded with dynamic volume routing to support VWMA Slowing/Signals #property description "Barbara Star's DMI Stochastic Oscillator. Supports Standard and Heikin Ashi sources." //--- Indicator Window and Plot Properties --- @@ -39,7 +39,7 @@ //--- Input Parameters --- input ENUM_CANDLE_SOURCE InpCandleSource = CANDLE_STANDARD; // Candle source -input ENUM_DMI_OSC_TYPE InpOscType = OSC_PDI_MINUS_NDI; // Oscillator Formula +input ENUM_DMI_OSC_TYPE InpOscType = OSC_PDI_MINUS_NDI; // Oscillator Formula input int InpDMIPeriod = 10; // DMI Period input int InpFastKPeriod = 10; // Stochastic %K Period input int InpSlowKPeriod = 3; // Stochastic %K Slowing @@ -114,7 +114,18 @@ int OnCalculate(const int rates_total, if(CheckPointer(g_calculator) == POINTER_INVALID) return(0); - g_calculator.Calculate(rates_total, prev_calculated, open, high, low, close, BufferK, BufferD); +//--- Determine best volume array (Use Real Volume if available, otherwise fallback to Tick Volume) + long volume_limit = (long)SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_LIMIT); + +//--- Delegate calculations dynamically to support volume-weighted types (VWMA) on Slowing/Signal + if(volume_limit > 0) + { + g_calculator.Calculate(rates_total, prev_calculated, open, high, low, close, volume, BufferK, BufferD); + } + else + { + g_calculator.Calculate(rates_total, prev_calculated, open, high, low, close, tick_volume, BufferK, BufferD); + } return(rates_total); }