diff --git a/Indicators/MyIndicators/Authors/Ehlers/2_Oscillators/RSIH_Pro.mq5 b/Indicators/MyIndicators/Authors/Ehlers/2_Oscillators/RSIH_Pro.mq5 index 8e31d34..020fb3b 100644 --- a/Indicators/MyIndicators/Authors/Ehlers/2_Oscillators/RSIH_Pro.mq5 +++ b/Indicators/MyIndicators/Authors/Ehlers/2_Oscillators/RSIH_Pro.mq5 @@ -1,10 +1,9 @@ //+------------------------------------------------------------------+ //| RSIH_Pro.mq5 | -//| Copyright 2025, xxxxxxxx| -//| | +//| Copyright 2026, xxxxxxxx| //+------------------------------------------------------------------+ -#property copyright "Copyright 2025, xxxxxxxx" -#property version "2.00" // Added optional Noise Elimination Technology (NET) +#property copyright "Copyright 2026, xxxxxxxx" +#property version "3.10" // Fixed visual consistency #property description "John Ehlers' Improved RSI with Hann Windowing (RSIH) and optional NET filter." #property indicator_separate_window @@ -14,24 +13,26 @@ //--- Plot 1: Base RSIH #property indicator_label1 "RSIH" #property indicator_type1 DRAW_LINE -#property indicator_color1 clrGray -#property indicator_style1 STYLE_DOT +#property indicator_color1 clrDodgerBlue // Fixed color +#property indicator_style1 STYLE_SOLID // Fixed style #property indicator_width1 1 //--- Plot 2: NET-filtered RSIH #property indicator_label2 "NET(RSIH)" #property indicator_type2 DRAW_LINE -#property indicator_color2 clrDodgerBlue -#property indicator_style2 STYLE_SOLID -#property indicator_width2 1 +#property indicator_color2 clrGray +#property indicator_style2 STYLE_DOT +#property indicator_width2 1 // Thicker line for emphasis -#property indicator_minimum -1.1 -#property indicator_maximum 1.1 -#property indicator_level1 0.5 -#property indicator_level2 0.0 -#property indicator_level3 -0.5 -#property indicator_levelcolor clrGray -#property indicator_levelstyle STYLE_DOT +#property indicator_minimum -1 +#property indicator_maximum 1 +#property indicator_level1 0.75 +#property indicator_level2 0.5 +#property indicator_level3 0.0 +#property indicator_level4 -0.5 +#property indicator_level5 -0.75 +//#property indicator_levelcolor clrGray +//#property indicator_levelstyle STYLE_DOT #include @@ -49,6 +50,8 @@ double BufferNET[]; //--- Global calculator object --- CRSIHCalculator *g_calculator; +//+------------------------------------------------------------------+ +//| OnInit | //+------------------------------------------------------------------+ int OnInit() { @@ -58,15 +61,9 @@ int OnInit() ArraySetAsSeries(BufferNET, false); if(InpSourcePrice <= PRICE_HA_CLOSE) - { g_calculator = new CRSIHCalculator_HA(); - IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("RSIH HA(%d,%d)", InpPeriodRSI, InpPeriodNET)); - } else - { g_calculator = new CRSIHCalculator(); - IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("RSIH(%d,%d)", InpPeriodRSI, InpPeriodNET)); - } if(CheckPointer(g_calculator) == POINTER_INVALID || !g_calculator.Init(InpPeriodRSI, InpPeriodNET)) { @@ -74,6 +71,10 @@ int OnInit() return(INIT_FAILED); } + string netStr = InpApplyNET ? StringFormat(", NET %d", InpPeriodNET) : ""; + string type = (InpSourcePrice <= PRICE_HA_CLOSE) ? " HA" : ""; + IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("RSIH%s(%d%s)", type, InpPeriodRSI, netStr)); + PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, InpPeriodRSI + 1); PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, InpPeriodRSI + InpPeriodNET + 1); IndicatorSetInteger(INDICATOR_DIGITS, 2); @@ -81,6 +82,8 @@ int OnInit() return(INIT_SUCCEEDED); } +//+------------------------------------------------------------------+ +//| OnDeinit | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { @@ -89,38 +92,38 @@ void OnDeinit(const int reason) } //+------------------------------------------------------------------+ -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&[]) +//| OnCalculate | +//+------------------------------------------------------------------+ +int OnCalculate(const int rates_total, + const int prev_calculated, + const datetime &time[], + const double &open[], + const double &high[], + const double &low[], + const double &close[], + const long &tick_volume[], + const long &volume[], + const int &spread[]) { - if(CheckPointer(g_calculator) == POINTER_INVALID) - return 0; + if(rates_total < InpPeriodRSI + 1) + return(0); - ENUM_APPLIED_PRICE price_type; - if(InpSourcePrice <= PRICE_HA_CLOSE) - price_type = (ENUM_APPLIED_PRICE)(-(int)InpSourcePrice); - else - price_type = (ENUM_APPLIED_PRICE)InpSourcePrice; + 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, BufferRSIH, BufferNET); + g_calculator.Calculate(rates_total, prev_calculated, price_type, open, high, low, close, + BufferRSIH, BufferNET); -// Hide buffers if not enabled by the user +// Visual Logic: Hide NET buffer if not enabled if(!InpApplyNET) { - for(int i=0; i 0) ? prev_calculated - 1 : 0; + for(int i = start; i < rates_total; i++) BufferNET[i] = EMPTY_VALUE; - // If NET is off, make the base RSIH the main line - PlotIndexSetInteger(0, PLOT_LINE_STYLE, STYLE_SOLID); - PlotIndexSetInteger(0, PLOT_LINE_COLOR, clrDodgerBlue); - } - } - else - { - // Restore default styles if NET is on - PlotIndexSetInteger(0, PLOT_LINE_STYLE, STYLE_DOT); - PlotIndexSetInteger(0, PLOT_LINE_COLOR, clrGray); } +// Removed dynamic style changing logic for RSIH return(rates_total); } //+------------------------------------------------------------------+ -//+------------------------------------------------------------------+