From e63abd36fbdf4eca5c164b5364955cdbd04ce2e4 Mon Sep 17 00:00:00 2001 From: Toh4iem9 Date: Tue, 21 Oct 2025 10:57:40 +0200 Subject: [PATCH] refactor: Added optional Noise Elimination Technology (NET) --- Indicators/MyIndicators/RSIH_Pro.mq5 | 74 ++++++++++++++++++---------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/Indicators/MyIndicators/RSIH_Pro.mq5 b/Indicators/MyIndicators/RSIH_Pro.mq5 index ec233a4..8fe5aaa 100644 --- a/Indicators/MyIndicators/RSIH_Pro.mq5 +++ b/Indicators/MyIndicators/RSIH_Pro.mq5 @@ -4,18 +4,27 @@ //| | //+------------------------------------------------------------------+ #property copyright "Copyright 2025, xxxxxxxx" -#property version "1.00" -#property description "John Ehlers' Improved RSI with Hann Windowing (RSIH)." +#property version "2.00" // Added optional Noise Elimination Technology (NET) +#property description "John Ehlers' Improved RSI with Hann Windowing (RSIH) and optional NET filter." #property indicator_separate_window -#property indicator_buffers 1 -#property indicator_plots 1 +#property indicator_buffers 2 +#property indicator_plots 2 + +//--- Plot 1: Base RSIH #property indicator_label1 "RSIH" #property indicator_type1 DRAW_LINE #property indicator_color1 clrGray -#property indicator_style1 STYLE_SOLID +#property indicator_style1 STYLE_DOT #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_minimum -1.1 #property indicator_maximum 1.1 #property indicator_level1 0.5 @@ -26,33 +35,25 @@ #include -//--- Custom Enum for Price Source, including Heikin Ashi enum ENUM_APPLIED_PRICE_HA_ALL { -//--- Heikin Ashi Prices - PRICE_HA_CLOSE = -1, - PRICE_HA_OPEN = -2, - PRICE_HA_HIGH = -3, - PRICE_HA_LOW = -4, - PRICE_HA_MEDIAN = -5, - PRICE_HA_TYPICAL = -6, - PRICE_HA_WEIGHTED = -7, -//--- Standard Prices - PRICE_CLOSE_STD = PRICE_CLOSE, - PRICE_OPEN_STD = PRICE_OPEN, - PRICE_HIGH_STD = PRICE_HIGH, - PRICE_LOW_STD = PRICE_LOW, - PRICE_MEDIAN_STD = PRICE_MEDIAN, - PRICE_TYPICAL_STD = PRICE_TYPICAL, - PRICE_WEIGHTED_STD = PRICE_WEIGHTED + PRICE_HA_CLOSE = -1, PRICE_HA_OPEN = -2, PRICE_HA_HIGH = -3, PRICE_HA_LOW = -4, + PRICE_HA_MEDIAN = -5, PRICE_HA_TYPICAL = -6, PRICE_HA_WEIGHTED = -7, + PRICE_CLOSE_STD = PRICE_CLOSE, PRICE_OPEN_STD = PRICE_OPEN, PRICE_HIGH_STD = PRICE_HIGH, + PRICE_LOW_STD = PRICE_LOW, PRICE_MEDIAN_STD = PRICE_MEDIAN, PRICE_TYPICAL_STD = PRICE_TYPICAL, + PRICE_WEIGHTED_STD= PRICE_WEIGHTED }; //--- Input Parameters --- input int InpPeriodRSI = 14; input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD; +input group "Noise Elimination Technology (NET)" +input bool InpApplyNET = true; +input int InpPeriodNET = 14; //--- Indicator Buffers --- double BufferRSIH[]; +double BufferNET[]; //--- Global calculator object --- CRSIHCalculator *g_calculator; @@ -61,26 +62,29 @@ CRSIHCalculator *g_calculator; int OnInit() { SetIndexBuffer(0, BufferRSIH, INDICATOR_DATA); + SetIndexBuffer(1, BufferNET, INDICATOR_DATA); ArraySetAsSeries(BufferRSIH, false); + ArraySetAsSeries(BufferNET, false); if(InpSourcePrice <= PRICE_HA_CLOSE) { g_calculator = new CRSIHCalculator_HA(); - IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("RSIH HA(%d)", InpPeriodRSI)); + IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("RSIH HA(%d,%d)", InpPeriodRSI, InpPeriodNET)); } else { g_calculator = new CRSIHCalculator(); - IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("RSIH(%d)", InpPeriodRSI)); + IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("RSIH(%d,%d)", InpPeriodRSI, InpPeriodNET)); } - if(CheckPointer(g_calculator) == POINTER_INVALID || !g_calculator.Init(InpPeriodRSI)) + if(CheckPointer(g_calculator) == POINTER_INVALID || !g_calculator.Init(InpPeriodRSI, InpPeriodNET)) { Print("Failed to create or initialize RSIH Calculator object."); return(INIT_FAILED); } PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, InpPeriodRSI + 1); + PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, InpPeriodRSI + InpPeriodNET + 1); IndicatorSetInteger(INDICATOR_DIGITS, 2); return(INIT_SUCCEEDED); @@ -105,7 +109,25 @@ int OnCalculate(const int rates_total, const int, const datetime&[], const doubl else price_type = (ENUM_APPLIED_PRICE)InpSourcePrice; - g_calculator.Calculate(rates_total, price_type, open, high, low, close, BufferRSIH); + g_calculator.Calculate(rates_total, price_type, open, high, low, close, BufferRSIH, BufferNET); + +// Hide buffers if not enabled by the user + if(!InpApplyNET) + { + for(int i=0; i