Hidden Divergence Breakout RSI Reversal All Filter
- Indicatori
- Versione: 1.0
- Attivazioni: 5
Hidden Divergence Breakout RSI Reversal All Filter
Product Overview
Breakout Divergent is a technical analysis indicator for MetaTrader 4 (MT4) designed to identify Regular and Hidden RSI divergences alongside dynamic trendline breakout confirmations. Built for multi-asset price action and momentum analysis, the tool combines automated swing pivot detection, visual divergence trendlines, an ATR-based risk-to-reward target projection module, and an integrated 15-module multi-indicator confirmation framework. By unifying oscillator divergence, structural trendline breakouts, and customizable trend or volatility filters in one chart utility, it delivers structured visual signals and multi-channel alerts without cluttering the workspace.
Operating Principle and Signal Logic
The indicator evaluates price structure relative to the Relative Strength Index (RSI) on closed candles to prevent premature signal fluctuations on active bars. Core signals are processed using confirmed swing pivots and completed candle closes, ensuring that once a divergence or breakout arrow plots on a historical closed bar, it remains fixed and does not repaint or disappear. If the optional Fibonacci Retracement Filter is enabled, swing evaluation relies on a ZigZag-based lookback structure to identify recent high and low anchors before validating closed-bar signals.
- Swing Pivot Identification: The algorithm scans historical bars within a defined lookback window to locate valid swing highs and swing lows confirmed by a specified number of left and right surrounding bars.
- Regular Bullish Divergence (Buy Signal): Triggered when price forms a lower swing low while the RSI forms a higher swing low, indicating weakening downward momentum. A bullish arrow is plotted below the confirmed pivot bar when all enabled confirmation filters are satisfied.
- Regular Bearish Divergence (Sell Signal): Triggered when price forms a higher swing high while the RSI forms a lower swing high, indicating weakening upward momentum. A bearish arrow is plotted above the confirmed pivot bar when all enabled confirmation filters are satisfied.
- Hidden Bullish Divergence (Buy Signal): Triggered during an uptrend pullback when price forms a higher swing low while the RSI forms a lower swing low, signaling potential trend continuation when active filters align.
- Hidden Bearish Divergence (Sell Signal): Triggered during a downtrend rally when price forms a lower swing high while the RSI forms a higher swing high, signaling potential downward continuation when active filters align.
- Trendline Breakout Confirmation (Breakout Buy / Sell): Each detected divergence connects the two reference price pivots via an internal slope projection. When a subsequent closed candle breaks and closes across that projected divergence trendline in the direction of the divergence bias and satisfies all active filters, a secondary Breakout Buy or Breakout Sell arrow is generated.
- Multi-Filter Confluence Gate: Every candidate divergence or breakout signal passes through the Universal 15-Filter Framework using strict sequential AND logic. If multiple filters are enabled simultaneously, every active filter condition must return true on the evaluated closed bar for the signal arrow and alert to trigger.
- Exit and Target Management: As a visual charting indicator, trade exits are guided by dynamic ATR-based Stop Loss (SL) and three Take Profit levels (TP1 at 1R, TP2 at 2R, TP3 at 3R) drawn on the chart for the most recent signal, or by the appearance of an opposing confirmed divergence or breakout signal.
Key Technical Features
- Four Distinct Signal Modes: Independent boolean toggles allow traders to display Regular Divergence, Hidden Divergence, Trendline Breakout signals, or any combination simultaneously on the same chart.
- Automated Divergence Trendlines: Draws non-extending trendline segments directly between qualifying swing pivots on the main price chart (Lime for bullish setups, Red for bearish setups) for immediate structural clarity.
- Dynamic ATR Risk-to-Reward Levels: Automatically computes volatility-adjusted Entry, Stop Loss, and three progressive Take Profit levels (1:1, 1:2, and 1:3 risk-to-reward ratios) based on the Average True Range (ATR) of the latest closed signal bar.
- Universal 15-Filter Confirmation Suite: Integrates 15 modular, independently toggleable technical filters covering momentum oscillators, trend-following moving averages, volatility regimes, Ichimoku cloud structure, candlestick smoothing, and support/resistance or Fibonacci retracement zones.
- Non-Repainting Closed-Bar Execution: Signals are evaluated on completed candles (Bar 1 and confirmed pivot offsets), preventing mid-candle flickering and ensuring reliable visual inspection across historical data.
- Multi-Channel Alert System: Supports MetaTrader 4 terminal pop-up alerts, customizable WAV sound alerts, and mobile push notifications to the MetaTrader iOS/Android app with duplicate-message suppression within the active bar period.
- Automatic Broker Digit Adaptation: Automatically scales point-based offsets and support/resistance tolerance zones for both 4-digit and 5-digit forex brokers as well as metals and indices.
Visual Interface Elements (GUI)
- Aqua Upward Arrow (Buffer 0): Indicates a confirmed Bullish Divergence signal (Regular or Hidden) plotted below the signal candle low by the configured point offset.
- Red Downward Arrow (Buffer 1): Indicates a confirmed Bearish Divergence signal (Regular or Hidden) plotted above the signal candle high by the configured point offset.
- DodgerBlue Upward Arrow (Buffer 2): Indicates a confirmed Breakout Buy signal where a closed candle finishes above a bullish divergence trendline.
- Magenta Downward Arrow (Buffer 3): Indicates a confirmed Breakout Sell signal where a closed candle finishes below a bearish divergence trendline.
- Divergence Trendline Segments: Lime trendline segments connect qualifying bullish price lows; Red trendline segments connect qualifying bearish price highs without extending infinitely across future bars.
- ATR Target Lines and Labels: Horizontal segments with left-anchored price labels on the right edge mark the Entry price (Gold solid line), Stop Loss (Red dashed line), TP1 at 1R (LimeGreen dashed line), TP2 at 2R (MediumSeaGreen dashed line), and TP3 at 3R (DodgerBlue dashed line) exclusively for the latest active setup.
Practical Filter Combination Workflows
- Trend-Following Pullback Setup: Enable Show_Hidden and Show_Breakout alongside Filter 6 (Double MA Crossover) or Filter 15 (Supertrend) to isolate continuation divergences aligned with the dominant higher-timeframe trend direction.
- Reversal Structure Setup: Enable Show_Regular alongside Filter 14 (Support/Resistance Zone or Fibonacci Retracement) and Filter 2 (ADX Trend Strength) to filter reversal divergences occurring near key structural price levels.
- Momentum Confirmation Setup: Combine core RSI divergence with Filter 7 (Awesome Oscillator Color/Zero) or Filter 13 (MACD Histogram/Zero) to require multi-oscillator momentum agreement before plotting arrows.
Operation and Setup Recommendations
- Supported Instruments: Applicable to all liquid Forex pairs (such as EURUSD, GBPUSD, USDJPY, AUDUSD, USDCAD), precious metals (XAUUSD, XAGUSD), stock indices, and crypto CFDs available in MT4. Always evaluate instrument spread, tick size, and point characteristics before live deployment.
- Recommended Timeframes: Compatible with all standard MT4 timeframes from M1 to MN1. Intraday traders typically apply M15, M30, or H1, while swing traders utilize H4 or D1. Lower timeframes (M1, M5) are typically paired with higher-period trend filters such as Double MA, Ichimoku Senkou Span B, or Supertrend to reduce market noise.
- Account and Execution Environment: Works on both Hedging and Netting MT4 accounts and supports 4-digit and 5-digit broker pricing automatically. Standard or ECN accounts with low to moderate spreads are recommended, particularly when acting on breakout signals on lower timeframes.
- Computational Efficiency and Terminal Performance: The indicator is optimized to recalculate only newly formed bars after initial chart loading. However, enabling recursive filters (such as Heiken Ashi series, Supertrend, or Fibonacci ZigZag scanning) across a large number of simultaneously open charts may increase CPU and memory usage. Keep unused filter modules disabled and avoid opening excessive simultaneous chart windows on lower-spec systems.
Installation and Quick-Start Guide
- Step 1 (Attach to Chart): Open your desired symbol and timeframe in MetaTrader 4, locate Breakout Divergent in the Navigator panel under Indicators, and drag it onto the chart.
- Step 2 (Select Signal Types): In the Inputs tab, choose whether to display Regular Divergence, Hidden Divergence, Trendline Breakout arrows, or all three simultaneously.
- Step 3 (Configure Filters): Leave all 15 filters disabled for raw divergence and breakout detection, or enable one or more trend, volatility, or structural filters to require strict multi-indicator confluence.
- Step 4 (Enable Notifications): To receive mobile push alerts, configure your MetaQuotes ID inside MT4 Tools > Options > Notifications before setting Push_On to true.
- Chart Object Cleanup: All divergence trendlines (prefixed DivTL_) and ATR target projections (prefixed DivSLTP_) are managed automatically and removed cleanly from the chart when the indicator is detached or reinitialized.
Buffer Integration for External Expert Advisors
- Buffer 0 (Bullish Divergence): Stores the price coordinate below the bar low when a Regular or Hidden Bullish Divergence occurs, or EMPTY_VALUE when no signal is present.
- Buffer 1 (Bearish Divergence): Stores the price coordinate above the bar high when a Regular or Hidden Bearish Divergence occurs, or EMPTY_VALUE when no signal is present.
- Buffer 2 (Breakout Buy): Stores the price coordinate below the bar low when a bullish trendline breakout closes, or EMPTY_VALUE when inactive.
- Buffer 3 (Breakout Sell): Stores the price coordinate above the bar high when a bearish trendline breakout closes, or EMPTY_VALUE when inactive.
- Automated Strategy Compatibility: Developers and algorithmic traders can read Buffers 0 through 3 directly via the standard MQL4 iCustom() function on Bar 1 (or Bar Swing_Right + 1) to integrate filtered divergence and breakout signals into custom scripts or automated systems.
Input Parameters Documentation
Note: Visual separator strings (InpDivergenceGroup, InpSLTPGroup, and InpFilter1 through InpFilter15) act solely as section headers in the MT4 Inputs tab to organize the parameters below.
1. Divergence and Notification Settings
- RSI_Period (Default: 8) -> Number of bars used to calculate the internal RSI oscillator for divergence detection (in bars).
- RSI_Price (Default: PRICE_CLOSE) -> Applied price series used for the divergence RSI calculation (Close, Open, High, Low, Median, Typical, or Weighted).
- Swing_Left (Default: 3) -> Minimum number of bars to the left required to validate a price swing high or swing low (in bars).
- Swing_Right (Default: 3) -> Minimum number of bars to the right required to confirm a price swing high or swing low (in bars).
- Lookback (Default: 80) -> Maximum number of historical bars scanned backward from the current pivot to locate a prior comparison pivot (in bars).
- Show_Regular (Default: true) -> Enables or disables detection and plotting of Regular Bullish and Regular Bearish divergence signals.
- Show_Hidden (Default: true) -> Enables or disables detection and plotting of Hidden Bullish and Hidden Bearish divergence signals.
- Show_Breakout (Default: true) -> Enables or disables secondary Breakout Buy and Breakout Sell signals when price closes across a divergence trendline.
- Draw_Trendline (Default: true) -> Enables or disables drawing of connecting divergence trendline segments on the price chart.
- Alert_On (Default: true) -> Enables or disables standard MetaTrader 4 pop-up alert windows when a new signal triggers.
- Sound_On (Default: true) -> Enables or disables audible WAV sound notifications upon signal generation.
- Sound_File (Default: "alert.wav") -> Name of the audio file located in the MT4 Sounds directory played when Sound_On is active.
- Push_On (Default: true) -> Enables or disables push notifications sent to the user mobile device via MetaQuotes ID.
- Arrow_Offset (Default: 30) -> Vertical spacing distance between the candle high/low and plotted signal arrows (in points; breakout arrows plot at twice this offset).
2. ATR and Target Levels (SL/TP) Settings
- Show_SLTP (Default: true) -> Enables or disables drawing of Entry, Stop Loss, and TP1-TP3 horizontal projection lines for the latest signal.
- ATR_Period (Default: 7) -> Lookback period used to compute the Average True Range volatility value at the signal candle (in bars).
- ATR_Multiplier (Default: 1.5) -> Multiplier applied to the ATR value to determine the Stop Loss distance (1R risk unit).
- Line_Right_Bars (Default: 1) -> Number of bar periods to extend the horizontal Entry, SL, and TP lines to the right of candle 0 (in bars).
- Label_Font_Size (Default: 8) -> Font size used for the Entry, SL, TP1, TP2, and TP3 price labels on the chart (in points).
- Entry_Color (Default: clrGold) -> Line and label color for the reference Entry price level.
- SL_Color (Default: clrRed) -> Line and label color for the ATR-calculated Stop Loss level.
- TP1_Color (Default: clrLimeGreen) -> Line and label color for the first Take Profit target at 1:1 risk-to-reward.
- TP2_Color (Default: clrMediumSeaGreen) -> Line and label color for the second Take Profit target at 2:1 risk-to-reward.
- TP3_Color (Default: clrDodgerBlue) -> Line and label color for the third Take Profit target at 3:1 risk-to-reward.
- Target_Line_Style (Default: STYLE_DASH) -> Line style applied to the SL, TP1, TP2, and TP3 projection lines (Solid, Dash, Dot, DashDot, DashDotDot).
- Target_Line_Width (Default: 1) -> Thickness width of the Entry, SL, and TP horizontal projection lines (in pixels).
3. Universal 15-Filter Framework Settings
Filter 1: RSI Cross Filter
- Use_RSI_Cross_Filter (Default: false) -> Enables or disables confirmation requiring a separate RSI oscillator to cross out of oversold or overbought zones on the closed bar.
- RSI_Length (Default: 14) -> Averaging period for the RSI Cross filter oscillator (in bars).
- RSI_Price_Source (Default: PRICE_CLOSE) -> Applied price type used by both the RSI Cross filter and the RSI 75 filter.
- RSI_Oversold (Default: 30.0) -> Lower threshold level that RSI must cross upward from (previous bar at or below threshold, current closed bar above) to permit Buy signals (in RSI units).
- RSI_Overbought (Default: 70.0) -> Upper threshold level that RSI must cross downward from (previous bar at or above threshold, current closed bar below) to permit Sell signals (in RSI units).
Filter 2: ADX Trend Strength Filter
- Use_ADX_Filter (Default: false) -> Enables or disables minimum trend strength filtering via the Average Directional Index (ADX) main line.
- ADX_Period (Default: 10) -> Calculation period for the ADX trend strength indicator (in bars).
- ADX_Min_Level (Default: 20.0) -> Minimum ADX main line value required on the signal bar to allow either Buy or Sell signals, filtering out low-momentum ranging markets (in ADX units).
Filter 3: Single Moving Average Filter
- Use_MA_Filter (Default: false) -> Enables or disables directional trend filtering using a single Moving Average (requires close price above MA for Buy and below MA for Sell).
- MA_Period (Default: 50) -> Lookback period for the Single Moving Average filter (in bars).
- MA_Method (Default: MODE_SMA) -> Smoothing method applied to the Single MA calculation (SMA, EMA, SMMA, or LWMA).
- MA_Shift (Default: 0) -> Horizontal bar shift applied to the Single MA line (in bars).
Filter 4: Ichimoku Senkou Span B Filter
- Use_Ichimoku_Filter (Default: false) -> Enables or disables macro trend filtering against the Ichimoku Kinko Hyo Senkou Span B cloud boundary (Buy above Senkou Span B, Sell below Senkou Span B).
- Ichimoku_Tenkan (Default: 9) -> Tenkan-sen (Conversion Line) calculation period (in bars).
- Ichimoku_Kijun (Default: 26) -> Kijun-sen (Base Line) calculation period (in bars).
- Ichimoku_SenkouB (Default: 52) -> Senkou Span B (Leading Span B) calculation period used as the directional price threshold (in bars).
Filter 5: RSI 75 Midline Filter
- Use_RSI75_Filter (Default: false) -> Enables or disables long-period RSI 50-level midline trend filtering (requires RSI value above 50.0 for Buy and below 50.0 for Sell).
- RSI_Filter_Period (Default: 75) -> Lookback period for the long-term RSI midline trend filter (in bars).
Filter 6: Double Moving Average Crossover Filter
- Use_DoubleMA_Filter (Default: false) -> Enables or disables dual Moving Average trend alignment filtering (requires fast MA A above slow MA B for Buy, and MA A below MA B for Sell).
- MA_A_Period (Default: 30) -> Lookback period for the fast Moving Average A (in bars).
- MA_A_Method (Default: MODE_EMA) -> Moving average smoothing method for MA A (SMA, EMA, SMMA, or LWMA).
- MA_A_Applied (Default: PRICE_CLOSE) -> Applied price source used for MA A calculation.
- MA_A_Shift (Default: 0) -> Horizontal bar shift for MA A (in bars).
- MA_B_Period (Default: 140) -> Lookback period for the slow Moving Average B (in bars).
- MA_B_Method (Default: MODE_EMA) -> Moving average smoothing method for MA B (SMA, EMA, SMMA, or LWMA).
- MA_B_Applied (Default: PRICE_CLOSE) -> Applied price source used for MA B calculation.
- MA_B_Shift (Default: 0) -> Horizontal bar shift for MA B (in bars).
Filter 7: Awesome Oscillator (AO) Filter
- Use_AO_Filter (Default: false) -> Primary toggle to enable Bill Williams Awesome Oscillator momentum confirmation conditions.
- Use_AO_Volume_Filter (Default: false) -> Requires AO histogram amplitude to meet minimum positive or negative magnitude thresholds.
- AO_Buy_Min (Default: 4.0) -> Minimum positive AO value required to validate Buy signals when Use_AO_Volume_Filter is active (in AO units).
- AO_Sell_Max (Default: -4.0) -> Maximum negative AO value required to validate Sell signals when Use_AO_Volume_Filter is active (in AO units).
- Use_AO_Color_Filter (Default: false) -> Requires AO histogram bar-to-bar slope direction to rise for Buy (green bar) or fall for Sell (red bar).
- Use_AO_Zero_Filter (Default: false) -> Requires AO histogram to be both rising above the 0.0 zero line for Buy or falling below 0.0 for Sell.
Filter 8: Parabolic SAR Filter
- Use_SAR_Filter (Default: false) -> Enables or disables trend filtering using Parabolic Stop and Reverse dot placement relative to the signal bar close price (Buy above SAR, Sell below SAR).
- SAR_Step (Default: 0.02) -> Acceleration factor step increment for the Parabolic SAR calculation.
- SAR_Maximum (Default: 0.2) -> Maximum acceleration factor cap for the Parabolic SAR calculation.
Filter 9: Heiken Ashi Candle Filter
- Use_HeikenAshi_Filter (Default: false) -> Enables or disables smoothed Heiken Ashi candle body polarity confirmation (bullish Heiken Ashi close above open for Buy, bearish close below open for Sell).
Filter 10: CCI Trend Filter
- Use_CCI_Filter (Default: false) -> Enables or disables Commodity Channel Index zero-line directional trend filtering (Buy when CCI > 0.0, Sell when CCI < 0.0).
- CCI_Period (Default: 50) -> Lookback period for the CCI Trend filter (in bars).
- CCI_Applied (Default: PRICE_CLOSE) -> Applied price series used for the CCI Trend calculation.
Filter 11: CCI Overbought and Oversold Filter
- Use_CCI_OBOS_Filter (Default: false) -> Enables or disables momentum expansion filtering beyond extreme Commodity Channel Index thresholds.
- CCI_OBOS_Period (Default: 14) -> Lookback period for the CCI OB/OS filter (in bars).
- CCI_OBOS_Applied (Default: PRICE_CLOSE) -> Applied price series used for the CCI OB/OS filter.
- CCI_Overbought (Default: 100.0) -> Upper CCI level that must be exceeded to permit Buy signals (in CCI units).
- CCI_Oversold (Default: -100.0) -> Lower CCI level that price momentum must drop below to permit Sell signals (in CCI units).
Filter 12: Relative Vigor Index (RVI) Filters
- Use_RVI_Filter (Default: false) -> Enables or disables RVI main line zero-level trend confirmation (Buy when RVI > 0.0, Sell when RVI < 0.0).
- RVI_Period (Default: 75) -> Lookback period for the RVI zero-line trend filter (in bars).
- Use_RVI_Signal_Filter (Default: false) -> Enables or disables RVI main line versus signal line crossover alignment (Buy when Main > Signal, Sell when Main < Signal).
- RVI_Signal_Period (Default: 20) -> Lookback period for the RVI main and signal line crossover filter (in bars).
Filter 13: MACD Filters
- Use_MACD_Filter (Default: false) -> Enables or disables MACD histogram polarity filtering (MACD main line above signal line for Buy, below signal line for Sell).
- MACD_FastEMA (Default: 12) -> Fast Exponential Moving Average period for the MACD calculation (in bars).
- MACD_SlowEMA (Default: 26) -> Slow Exponential Moving Average period for the MACD calculation (in bars).
- MACD_SignalSMA (Default: 9) -> Signal line Simple Moving Average period for the MACD calculation (in bars).
- MACD_Applied (Default: PRICE_CLOSE) -> Applied price source used for MACD calculation.
- Use_MACD_Zero_Filter (Default: false) -> Enables or disables MACD main line zero-level trend filtering (MACD main line above 0.0 for Buy, below 0.0 for Sell).
Filter 14: Support/Resistance and Fibonacci Filters
- Use_SR_Filter (Default: false) -> Enables or disables proximity validation against recent rolling Support (for Buy) and Resistance (for Sell) price levels.
- SR_Period (Default: 50) -> Number of historical bars scanned to establish local Support and Resistance boundaries (in bars).
- SR_Zone_Points (Default: 80) -> Tolerance buffer zone around Support and Resistance levels within which a candle touch or wick test is accepted (in points).
- Use_Fib_Filter (Default: false) -> Enables or disables price zone filtering between two configurable Fibonacci retracement ratios derived from detected swing pivots.
- Fib_Level_1 (Default: 0.382) -> First Fibonacci retracement ratio boundary (e.g., 38.2% retracement level).
- Fib_Level_2 (Default: 0.618) -> Second Fibonacci retracement ratio boundary (e.g., 61.8% retracement level).
- ZigZag_Depth (Default: 12) -> Minimum bar depth used to identify swing highs and lows for the Fibonacci anchor calculation (in bars).
- ZigZag_Deviation (Default: 5) -> Minimum price change threshold between consecutive swing points (in points).
- ZigZag_Backstep (Default: 3) -> Minimum bar spacing between consecutive swing highs or consecutive swing lows (in bars).
Filter 15: Supertrend Filter
- Use_Supertrend_Filter (Default: false) -> Enables or disables ATR-based Supertrend directional regime filtering (Uptrend state for Buy, Downtrend state for Sell).
- ST_AtrPeriod (Default: 10) -> Wilder ATR lookback length used to compute Supertrend volatility bands (in bars).
- ST_Factor (Default: 3.0) -> Volatility band multiplier factor controlling Supertrend sensitivity and trailing band distance.
Risk Disclaimer
Trading foreign exchange, commodities, indices, and other financial instruments on margin carries a high level of risk and may not be suitable for all investors. Past performance, historical signal visualization, or simulated testing results are not indicative of future trading outcomes. This software is strictly a technical analysis and charting utility designed to assist traders in identifying chart patterns and indicator confluences; it does not provide financial advice or promise trading profits. Test this indicator thoroughly on a MetaTrader 4 demo account across your preferred symbols and broker conditions before live trading.
