refactor: Added selectable signal line type

This commit is contained in:
Toh4iem9
2025-11-25 15:58:58 +01:00
parent 8fa534a8e4
commit a34cad5d07
@@ -5,8 +5,8 @@
//+------------------------------------------------------------------+ //+------------------------------------------------------------------+
#property copyright "Copyright 2025, xxxxxxxx" #property copyright "Copyright 2025, xxxxxxxx"
#property link "" #property link ""
#property version "1.00" #property version "1.10" // Added selectable signal line type
#property description "Histogram for the Laguerre MACD. To be used with MACD_Laguerre_Line_Pro." #property description "Histogram for the Laguerre MACD with a selectable signal line."
#property indicator_separate_window #property indicator_separate_window
#property indicator_buffers 1 #property indicator_buffers 1
@@ -23,12 +23,13 @@
//--- Input Parameters --- //--- Input Parameters ---
input group "Laguerre MACD Settings" input group "Laguerre MACD Settings"
input double InpGamma1 = 0.2; // Fast Laguerre Gamma (smaller value) input double InpGamma1 = 0.2; // Fast Laguerre Gamma (smaller value)
input double InpGamma2 = 0.8; // Slow Laguerre Gamma (larger value) input double InpGamma2 = 0.8; // Slow Laguerre Gamma (larger value)
input group "Signal Line Settings" input group "Signal Line Settings"
input int InpSignalPeriod = 9; input ENUM_SMOOTHING_METHOD_LAGUERRE InpSignalMAType = SMOOTH_Laguerre;
input ENUM_MA_TYPE InpSignalMAType = EMA; input int InpSignalPeriod = 9;
input double InpSignalGamma = 0.5;
input group "Price Source" input group "Price Source"
input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD; input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD;
@@ -50,15 +51,16 @@ int OnInit()
else else
g_calculator = new CMACDLaguerreHistogramCalculator(); g_calculator = new CMACDLaguerreHistogramCalculator();
if(CheckPointer(g_calculator) == POINTER_INVALID || !g_calculator.Init(InpGamma1, InpGamma2, InpSignalPeriod, InpSignalMAType)) if(CheckPointer(g_calculator) == POINTER_INVALID ||
!g_calculator.Init(InpGamma1, InpGamma2, InpSignalGamma, InpSignalPeriod, InpSignalMAType))
{ {
Print("Failed to create or initialize MACD Laguerre Histogram Calculator."); Print("Failed to create or initialize MACD Laguerre Histogram Calculator.");
return(INIT_FAILED); return(INIT_FAILED);
} }
string ma_name = EnumToString(InpSignalMAType); string ma_name = EnumToString(InpSignalMAType);
StringToUpper(ma_name); StringReplace(ma_name, "SMOOTH_", "");
IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("Laguerre Histo(%s,%d)", ma_name, InpSignalPeriod)); IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("Laguerre Histo(%s)", ma_name));
PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, 2 + InpSignalPeriod); PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, 2 + InpSignalPeriod);
IndicatorSetInteger(INDICATOR_DIGITS, _Digits); IndicatorSetInteger(INDICATOR_DIGITS, _Digits);