refactor: enums

This commit is contained in:
Toh4iem9
2025-11-12 14:25:31 +01:00
parent 84e37e85d7
commit fec6a50892
+16 -9
View File
@@ -4,9 +4,9 @@
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, xxxxxxxx"
#property version "3.22" // Fixed enum conflicts
#property description "A professional, unified RSI with selectable price source, a flexible"
#property description "signal line (incl. SuperSmoother), and optional Bollinger Bands."
#property version "3.10"
#property description "A professional, unified RSI with selectable price source (incl. Heikin Ashi),"
#property description "a flexible MA signal line, and optional Bollinger Bands."
#property indicator_separate_window
#property indicator_buffers 4
@@ -51,15 +51,14 @@ enum ENUM_DISPLAY_MODE
//--- Input Parameters ---
input group "RSI Settings"
input int InpPeriodRSI = 14;
input int InpPeriodRSI = 14;
input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD;
input group "Overlay Settings"
input ENUM_DISPLAY_MODE InpDisplayMode = DISPLAY_RSI_AND_BANDS;
input int InpPeriodMA = 20;
//--- UPDATED: Use the new, non-conflicting enum ---
input ENUM_SMOOTHING_METHOD InpMethodMA = SMOOTH_SMA;
input double InpBandsDev = 2.0;
input ENUM_DISPLAY_MODE InpDisplayMode = DISPLAY_RSI_AND_BANDS;
input int InpPeriodMA = 20;
input ENUM_MA_METHOD InpMethodMA = MODE_SMA;
input double InpBandsDev = 2.0;
//--- Indicator Buffers ---
double BufferRSI[], BufferSignalMA[], BufferUpperBand[], BufferLowerBand[];
@@ -76,6 +75,7 @@ int OnInit()
SetIndexBuffer(1, BufferSignalMA, INDICATOR_DATA);
SetIndexBuffer(2, BufferUpperBand, INDICATOR_DATA);
SetIndexBuffer(3, BufferLowerBand, INDICATOR_DATA);
ArraySetAsSeries(BufferRSI, false);
ArraySetAsSeries(BufferSignalMA, false);
ArraySetAsSeries(BufferUpperBand, false);
@@ -83,9 +83,15 @@ int OnInit()
//--- Dynamic Calculator Instantiation ---
if(InpSourcePrice <= PRICE_HA_CLOSE)
{
g_calculator = new CRSIProCalculator_HA();
IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("RSI Pro HA(%d)", InpPeriodRSI));
}
else
{
g_calculator = new CRSIProCalculator();
IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("RSI Pro(%d)", InpPeriodRSI));
}
if(CheckPointer(g_calculator) == POINTER_INVALID ||
!g_calculator.Init(InpPeriodRSI, InpPeriodMA, InpMethodMA, InpBandsDev))
@@ -99,6 +105,7 @@ int OnInit()
PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, draw_begin);
PlotIndexSetInteger(2, PLOT_DRAW_BEGIN, draw_begin);
PlotIndexSetInteger(3, PLOT_DRAW_BEGIN, draw_begin);
return(INIT_SUCCEEDED);
}