From 7261966fcc17ef3be6af3c5708bb25fb6b3e06a4 Mon Sep 17 00:00:00 2001 From: Toh4iem9 Date: Tue, 18 Nov 2025 14:11:45 +0100 Subject: [PATCH] refactor: Added customizable colors --- .../Polynomial_Regression_Object_Pro.mq5 | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Indicators/MyIndicators/Authors/Kaufman/Polynomial_Regression_Object_Pro.mq5 b/Indicators/MyIndicators/Authors/Kaufman/Polynomial_Regression_Object_Pro.mq5 index 834206d..9999791 100644 --- a/Indicators/MyIndicators/Authors/Kaufman/Polynomial_Regression_Object_Pro.mq5 +++ b/Indicators/MyIndicators/Authors/Kaufman/Polynomial_Regression_Object_Pro.mq5 @@ -4,20 +4,26 @@ //| | //+------------------------------------------------------------------+ #property copyright "Copyright 2025, xxxxxxxx" -#property version "1.00" +#property version "1.10" // Added customizable colors #property description "Draws a single, moving Curvilinear Regression Channel using objects." #property indicator_chart_window -#property indicator_buffers 0 // No buffers are used for plotting +#property indicator_buffers 0 #property indicator_plots 0 #include //--- Input Parameters --- +input group "Channel Settings" input int InpPeriod = 50; // Regression Period input double InpDeviation = 2.0; // Deviation for bands input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD; +input group "Color Settings" +input color InpMidlineColor = clrCrimson; // Midline Color +input color InpUpperBandColor = clrCrimson; // Upper Band Color +input color InpLowerBandColor = clrCrimson; // Lower Band Color + //--- Global variables --- CPolynomialRegressionObjectCalculator *g_calculator; string g_unique_prefix; @@ -25,10 +31,7 @@ string g_unique_prefix; //+------------------------------------------------------------------+ int OnInit() { -//--- Create a unique prefix for our objects g_unique_prefix = StringFormat("PolyRegObj_%d_%d", ChartID(), GetTickCount()); - -//--- Clean up any leftover objects from a previous run ObjectsDeleteAll(0, g_unique_prefix); if(InpSourcePrice <= PRICE_HA_CLOSE) @@ -36,7 +39,9 @@ int OnInit() else g_calculator = new CPolynomialRegressionObjectCalculator(); - if(CheckPointer(g_calculator) == POINTER_INVALID || !g_calculator.Init(InpPeriod, InpDeviation, g_unique_prefix)) +//--- Pass the new color parameters to Init --- + if(CheckPointer(g_calculator) == POINTER_INVALID || + !g_calculator.Init(InpPeriod, InpDeviation, g_unique_prefix, InpMidlineColor, InpUpperBandColor, InpLowerBandColor)) { Print("Failed to initialize Polynomial Regression Object Calculator."); return(INIT_FAILED); @@ -51,9 +56,7 @@ int OnInit() //+------------------------------------------------------------------+ void OnDeinit(const int reason) { -//--- Clean up our graphical objects ObjectsDeleteAll(0, g_unique_prefix); - if(CheckPointer(g_calculator) != POINTER_INVALID) delete g_calculator; } @@ -64,10 +67,7 @@ int OnCalculate(const int rates_total, const int, const datetime &time[], const 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; - -//--- The calculator now needs the time array for object placement g_calculator.Calculate(rates_total, time, price_type, open, high, low, close); - return(rates_total); } //+------------------------------------------------------------------+