refactor: Fixed missing input parameters

This commit is contained in:
Toh4iem9
2025-12-20 23:07:53 +01:00
parent 61be9c2a08
commit f2df02759d
+16 -16
View File
@@ -3,7 +3,7 @@
//| Copyright 2025, xxxxxxxx| //| Copyright 2025, xxxxxxxx|
//+------------------------------------------------------------------+ //+------------------------------------------------------------------+
#property copyright "Copyright 2025, xxxxxxxx" #property copyright "Copyright 2025, xxxxxxxx"
#property version "2.10" // Optimized for incremental calculation #property version "3.10" // Fixed missing input parameters
#property description "TSI Oscillator (Histogram of TSI vs Signal Line) with selectable" #property description "TSI Oscillator (Histogram of TSI vs Signal Line) with selectable"
#property description "price source (Standard and Heikin Ashi)." #property description "price source (Standard and Heikin Ashi)."
@@ -22,17 +22,21 @@
#include <MyIncludes\TSI_Oscillator_Calculator.mqh> #include <MyIncludes\TSI_Oscillator_Calculator.mqh>
//--- Input Parameters --- //--- Input Parameters ---
input group "TSI Calculation Settings"
input int InpSlowPeriod = 25; input int InpSlowPeriod = 25;
input ENUM_MA_TYPE InpSlowMAType = EMA; // Added missing input
input int InpFastPeriod = 13; input int InpFastPeriod = 13;
input ENUM_MA_TYPE InpFastMAType = EMA; // Added missing input
input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD; input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD;
input group "Signal Line Settings" input group "Signal Line Settings"
input int InpSignalPeriod = 13; input int InpSignalPeriod = 13;
input ENUM_MA_METHOD InpSignalMAType = MODE_EMA; input ENUM_MA_TYPE InpSignalMAType = EMA;
//--- Indicator Buffers --- //--- Indicator Buffers ---
double BufferOscillator[]; double BufferOscillator[];
//--- Global calculator object (as a base class pointer) --- //--- Global calculator object ---
CTSICalculatorOscillator *g_calculator; CTSICalculatorOscillator *g_calculator;
//+------------------------------------------------------------------+ //+------------------------------------------------------------------+
@@ -43,23 +47,20 @@ int OnInit()
SetIndexBuffer(0, BufferOscillator, INDICATOR_DATA); SetIndexBuffer(0, BufferOscillator, INDICATOR_DATA);
ArraySetAsSeries(BufferOscillator, false); ArraySetAsSeries(BufferOscillator, false);
if(InpSourcePrice <= PRICE_HA_CLOSE) g_calculator = new CTSICalculatorOscillator();
{
g_calculator = new CTSICalculatorOscillator_HA();
IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("TSI Osc HA(%d,%d,%d)", InpSlowPeriod, InpFastPeriod, InpSignalPeriod));
}
else
{
g_calculator = new CTSICalculatorOscillator_Std();
IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("TSI Osc(%d,%d,%d)", InpSlowPeriod, InpFastPeriod, InpSignalPeriod));
}
if(CheckPointer(g_calculator) == POINTER_INVALID || !g_calculator.Init(InpSlowPeriod, InpFastPeriod, InpSignalPeriod, InpSignalMAType)) bool use_ha = (InpSourcePrice <= PRICE_HA_CLOSE);
if(CheckPointer(g_calculator) == POINTER_INVALID ||
!g_calculator.Init(InpSlowPeriod, InpSlowMAType, InpFastPeriod, InpFastMAType, InpSignalPeriod, InpSignalMAType, use_ha))
{ {
Print("Failed to create or initialize TSI Oscillator Calculator object."); Print("Failed to create or initialize TSI Oscillator Calculator object.");
return(INIT_FAILED); return(INIT_FAILED);
} }
string type = use_ha ? " HA" : "";
IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("TSI Osc%s(%d,%d,%d)", type, InpSlowPeriod, InpFastPeriod, InpSignalPeriod));
int draw_begin = InpSlowPeriod + InpFastPeriod + InpSignalPeriod - 1; int draw_begin = InpSlowPeriod + InpFastPeriod + InpSignalPeriod - 1;
PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, draw_begin); PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, draw_begin);
IndicatorSetInteger(INDICATOR_DIGITS, 2); IndicatorSetInteger(INDICATOR_DIGITS, 2);
@@ -80,7 +81,7 @@ void OnDeinit(const int reason)
//| Custom indicator calculation function | //| Custom indicator calculation function |
//+------------------------------------------------------------------+ //+------------------------------------------------------------------+
int OnCalculate(const int rates_total, int OnCalculate(const int rates_total,
const int prev_calculated, // <--- Now used! const int prev_calculated,
const datetime &time[], const datetime &time[],
const double &open[], const double &open[],
const double &high[], const double &high[],
@@ -99,7 +100,6 @@ int OnCalculate(const int rates_total,
else else
price_type = (ENUM_APPLIED_PRICE)InpSourcePrice; price_type = (ENUM_APPLIED_PRICE)InpSourcePrice;
//--- Delegate calculation with prev_calculated optimization
g_calculator.Calculate(rates_total, prev_calculated, price_type, open, high, low, close, BufferOscillator); g_calculator.Calculate(rates_total, prev_calculated, price_type, open, high, low, close, BufferOscillator);
return(rates_total); return(rates_total);