From b6d257313bb5f2873164ab611139cc9d97fd0988 Mon Sep 17 00:00:00 2001 From: Toh4iem9 Date: Fri, 2 Jan 2026 23:38:16 +0100 Subject: [PATCH] refactor(indicators): Optimized for incremental calculation --- Indicators/MyIndicators/Authors/Kaufman/DPO_Pro.mq5 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Indicators/MyIndicators/Authors/Kaufman/DPO_Pro.mq5 b/Indicators/MyIndicators/Authors/Kaufman/DPO_Pro.mq5 index 964d9c2..8325fcb 100644 --- a/Indicators/MyIndicators/Authors/Kaufman/DPO_Pro.mq5 +++ b/Indicators/MyIndicators/Authors/Kaufman/DPO_Pro.mq5 @@ -1,10 +1,9 @@ //+------------------------------------------------------------------+ //| DPO_Pro.mq5 | //| Copyright 2025, xxxxxxxx| -//| | //+------------------------------------------------------------------+ #property copyright "Copyright 2025, xxxxxxxx" -#property version "1.00" +#property version "2.00" // Optimized for incremental calculation #property description "Detrended Price Oscillator (DPO). Shows cycles by removing the trend." #property indicator_separate_window @@ -14,7 +13,7 @@ #property indicator_type1 DRAW_LINE #property indicator_color1 clrDodgerBlue #property indicator_style1 STYLE_SOLID -#property indicator_width1 1 +#property indicator_width1 2 #property indicator_level1 0.0 #property indicator_levelstyle STYLE_DOT @@ -62,13 +61,14 @@ int OnInit() void OnDeinit(const int reason) { if(CheckPointer(g_calculator) != POINTER_INVALID) delete g_calculator; } //+------------------------------------------------------------------+ -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; ENUM_APPLIED_PRICE price_type = (InpSourcePrice <= PRICE_HA_CLOSE) ? (ENUM_APPLIED_PRICE)(-(int)InpSourcePrice) : (ENUM_APPLIED_PRICE)InpSourcePrice; - g_calculator.Calculate(rates_total, price_type, open, high, low, close, BufferDPO); + + g_calculator.Calculate(rates_total, prev_calculated, price_type, open, high, low, close, BufferDPO); + return(rates_total); } //+------------------------------------------------------------------+ -//+------------------------------------------------------------------+