EA Pro RSI Overbought oversold Multi Filter Trends
- Experts
- Versione: 2.30
- Attivazioni: 5
Overview
RSI OB OS EA is a systematic automated trading solution engineered for MetaTrader 5, developed to trade momentum reversals and trend continuations using the Relative Strength Index (RSI) combined with up to 14 selectable technical confirmation filters. The system executes trades strictly on bar opening (completed candle index 1), guaranteeing non-repainting signal logic where historical signals remain fixed and persistent. The Expert Advisor incorporates an adaptive position management framework equipped with dynamic ATR-based or point-based Stop Loss and Take Profit, automated Breakeven protection, multi-mode Trailing Stop mechanics, opposite-signal position clearing, dynamic account balance auto-lot allocation, broker margin verification routines, and comprehensive multi-channel notifications (Terminal Alert, Audio, Push Notification, and Email).
Technical Operating Principles and Signal Logic
1. Core Signal Engine:
The baseline trade generation relies on an 8-period Relative Strength Index calculated on closed bar prices. The algorithm monitors transitions through extreme threshold zones (Oversold 30.0 and Overbought 70.0). A Buy trigger condition occurs when the RSI value on candle index 2 is less than or equal to the Oversold threshold, and the RSI value on candle index 1 crosses above the Oversold threshold (Bullish Momentum Rebound: rsi[2] <= Oversold and rsi[1] > Oversold). A Sell trigger condition occurs when the RSI value on candle index 2 is greater than or equal to the Overbought threshold, and the RSI value on candle index 1 crosses below the Overbought threshold (Bearish Momentum Rejection: rsi[2] >= Overbought and rsi[1] < Overbought). Both conditions are evaluated exclusively on bar completion (IsNewBar), eliminating real-time flickering, false breakouts within an unclosed candle, and repainting behavior.
2. Multi-Filter Architecture:
Signals generated by the primary RSI engine must obtain concurrent validation from all active confirmation filters. When multiple filters are enabled simultaneously, logical AND gating is applied; every enabled module must validate the corresponding direction for trade execution to proceed.
- Average Directional Index (ADX) Filter: Evaluates market volatility and trend strength. Signals are permitted only when ADX main line value on bar 1 is greater than or equal to ADX_Min_Level (default 20.0), filtering out dormant and low-liquidity ranges.
- Single Moving Average (SMA) Filter: Compares bar 1 closing price against a period 50 Moving Average. Buy signals require Close[1] > MA[1]; Sell signals require Close[1] < MA[1].
- Ichimoku Senkou Span B Filter: Uses the 52-period leading cloud baseline shifted to reflect structural support/resistance. Buy trades are valid when Close[1] > SenkouB[1]; Sell trades require Close[1] < SenkouB[1].
- RSI 75 Trend Filter: Employs a macro 75-period RSI as a market regime filter. Buy signals require RSI75[1] > 50.0 (bullish half); Sell signals require RSI75[1] < 50.0 (bearish half).
- Double Exponential Moving Average (EMA) Cross Filter: Assesses trend direction using dual exponential moving averages (default 75 EMA fast and 140 EMA slow). Buy requires EMA_A[1] > EMA_B[1]; Sell requires EMA_A[1] < EMA_B[1].
- Awesome Oscillator (AO) Filter: Offers three distinct filtering modes based on median price momentum: Volume/Magnitude filter (AO[1] >= Buy_Min or AO[1] <= Sell_Max), Color/Slope filter (AO[1] > AO[2] for Buy; AO[1] < AO[2] for Sell), and Zero-Line Momentum filter (AO[1] > AO[2] and AO[1] > 0 for Buy; AO[1] < AO[2] and AO[1] < 0 for Sell).
- Parabolic SAR Filter: Determines structural trailing price position. Buy requires Close[1] > SAR[1]; Sell requires Close[1] < SAR[1].
- Heiken Ashi Smoothed Filter: Computes synthetic Heiken Ashi open and close prices on historical bar sets. Buy permits entry only when HA_Close[1] > HA_Open[1]; Sell requires HA_Close[1] < HA_Open[1].
- Commodity Channel Index (CCI) Trend Filter: Evaluates deviation from statistical mean over 50 periods. Buy requires CCI[1] > 0; Sell requires CCI[1] < 0.
- CCI Overbought/Oversold Filter: Detects extreme cyclical deviation across 14 periods. Buy requires CCI[1] > CCI_Overbought (+100); Sell requires CCI[1] < CCI_Oversold (-100).
- Relative Vigor Index (RVI) Trend Filter: Measures closing conviction over 75 periods. Buy requires RVI[1] > 0; Sell requires RVI[1] < 0.
- RVI Signal Line Cross Filter: Evaluates momentum crossovers between the RVI main line and signal line over 20 periods. Buy requires RVI_Main[1] > RVI_Signal[1]; Sell requires RVI_Main[1] < RVI_Signal[1].
- MACD Histogram Filter: Assesses convergence/divergence momentum. Buy requires MACD_Main[1] - MACD_Signal[1] > 0; Sell requires MACD_Main[1] - MACD_Signal[1] < 0.
- MACD Level Zero Filter: Analyzes MACD baseline positioning. Buy requires MACD_Main[1] > 0; Sell requires MACD_Main[1] < 0.
- Support and Resistance Zone Filter: Scans historical swing high and swing low extreme levels across a user-defined lookback period (default 50 bars) using a tolerance band (default 80 points). Buy is verified when bar 1 low tests or penetrates the support band; Sell is verified when bar 1 high tests or penetrates the resistance band.
- Fibonacci Retracement Filter: Automatically extracts recent ZigZag swing high and swing low inflection points, calculates Fibonacci levels between ratio 0.382 and 0.618, and validates execution only when price action interacts with the designated retracement zone.
3. Position and Order Execution Management:
- Opposite Signal Handling: When Close_Opposite_Signal is enabled, incoming Buy signals automatically liquidate any active Sell positions registered under the EA Magic Number, and incoming Sell signals liquidate active Buy positions.
- Position Limiting: When Use_Max_Entry is enabled, the EA counts active positions associated with the chart symbol and Magic Number, blocking new orders when the count reaches Max_Entry_Positions.
- Margin and Broker Volume Validation: Prior to sending market orders via CTrade, the lot size calculation checks broker requirements including SYMBOL_VOLUME_STEP, SYMBOL_VOLUME_MIN, SYMBOL_VOLUME_MAX, and broker account SYMBOL_VOLUME_LIMIT. The system calculates required margin through OrderCalcMargin; if available free margin is insufficient, lot size is stepped down systematically until margin requirements are satisfied. If minimum lot size cannot be funded, execution is safely aborted to prevent TRADE_RETCODE_NO_MONEY errors.
- Breakeven & Trailing Stops: Managed dynamically inside the OnTick event. Once price surpasses the specified Breakeven distance (manual points or dynamic ATR value), Stop Loss is adjusted to the position opening price. When Trailing Stop is enabled, once floating profit exceeds Trailing_Start_Value, the Stop Loss trails market price at the configured point or ATR trailing distance.
Recommended Operational Setup
- Instruments: Currency pairs (e.g., EURUSD, GBPUSD, AUDUSD, USDJPY), equity indices, and precious metals (XAUUSD). Because spreads impact short-term reversal efficiency, low-spread ECN accounts are recommended.
- Timeframes: Universal architecture compatible with M5, M15, M30, H1, and H4. Shorter timeframes (M5-M15) yield higher signal frequency, whereas higher timeframes (H1-H4) provide broader macro swings.
- Account Type: Hedging or Netting accounts in MetaTrader 5.
- VPS: Low-latency Virtual Private Server (VPS) is recommended when using real-time Trailing Stop or Breakeven functions to maintain continuous order tracking.
Complete Input Parameters Dictionary
1. RSI Main Settings (Entry Signal)
- Entry_Group (Default: "=== RSI MAIN SETTINGS ==="): Visual section separator for primary entry variables.
- RSI_Length (Default: 8): Averaging period for the core Relative Strength Index calculation. Lower values heighten sensitivity; higher values smooth oscillation.
- RSI_Price_Source (Default: PRICE_CLOSE): Price series utilized for RSI derivation (PRICE_CLOSE, PRICE_OPEN, PRICE_HIGH, PRICE_LOW, PRICE_MEDIAN, PRICE_TYPICAL, PRICE_WEIGHTED).
- Oversold (Default: 30.0): Numeric lower threshold where an upward crossover triggers a Buy entry signal.
- Overbought (Default: 70.0): Numeric upper threshold where a downward crossover triggers a Sell entry signal.
2. EA Management & Trade Logic
- EA_Group (Default: "=== EA MANAGEMENT ==="): Visual section separator for trade routing controls.
- MagicNumber (Default: 123456): Unique identifier assigned to orders executed by this EA instance, preventing conflicts with other programs or manual trades.
- Close_Opposite_Signal (Default: true): Boolean flag enabling automatic closure of opposite-direction open positions when a valid reverse trade signal occurs.
- Use_Max_Entry (Default: true): Enables an upper ceiling limit on total concurrent positions maintained per direction for this symbol and Magic Number.
- Max_Entry_Positions (Default: 20): Maximum number of allowable open positions per direction when Use_Max_Entry is enabled.
3. Lot Settings & Money Management
- Lot_Group (Default: "=== LOT SETTINGS ==="): Visual section separator for order volume calculation.
- Use_Auto_Lot (Default: true): Toggles automated lot sizing proportional to account balance. When false, Fixed_Lot is utilized.
- Fixed_Lot (Default: 0.01): Static volume in standard lots applied when Use_Auto_Lot is disabled.
- Auto_Lot_Balance (Default: 600.0): Reference account balance step (in deposit currency) used to calculate dynamic trading volume.
- Auto_Lot_Size (Default: 0.01): Base lot increment allocated per Auto_Lot_Balance unit. For instance, an account balance of 1200.0 with 600.0 reference allocates 0.02 lots.
4. Average True Range (ATR) Settings
- ATR_Group (Default: "=== ATR SETTINGS ==="): Visual section separator for volatility parameters.
- ATR_Period (Default: 10): Number of bars evaluated by the Average True Range indicator for volatility-scaled Stop Loss, Take Profit, Breakeven, and Trailing Stops.
5. Take Profit & Stop Loss Settings
- TPSL_Group (Default: "=== TP & SL SETTINGS ==="): Visual section separator for order exit constraints.
- Use_TP (Default: true): Enables assignment of protective Take Profit orders upon execution.
- Use_TP_ATR (Default: false): Toggles ATR-derived Take Profit distance. When true, TP distance matches the current ATR buffer value; when false, TP_Value points are applied.
- TP_Value (Default: 1000): Manual Take Profit offset measured in broker points (e.g., 1000 points = 100 pips on 5-digit pairs).
- Use_SL (Default: true): Enables assignment of protective Stop Loss orders upon execution.
- Use_SL_ATR (Default: false): Toggles ATR-derived Stop Loss distance. When true, SL distance matches the current ATR buffer value; when false, SL_Value points are applied.
- SL_Value (Default: 500): Manual Stop Loss offset measured in broker points (e.g., 500 points = 50 pips on 5-digit pairs).
6. Breakeven Settings
- BE_Group (Default: "=== BREAKEVEN SETTINGS ==="): Visual section separator for breakeven logic.
- Use_BE (Default: false): Enables automatic modification of Stop Loss to opening price once floating profit crosses the threshold distance.
- Use_BE_ATR (Default: false): Calculates the breakeven trigger distance using current ATR value instead of fixed points.
- BE_Value (Default: 200): Minimum profit distance in broker points required before the Stop Loss is adjusted to the position open price.
7. Trailing Stop Settings
- Trail_Group (Default: "=== TRAILING SETTINGS ==="): Visual section separator for dynamic trade trailing.
- Use_Trailing (Default: false): Enables automated tick-by-tick trailing stop tracking.
- Trailing_Start_Value (Default: 300): Minimum floating profit distance in broker points required before trailing mechanism activates.
- Use_Trailing_Stop_ATR (Default: false): Uses dynamic ATR buffer calculation for trailing step distance instead of fixed point values.
- Trailing_Stop_Value (Default: 500): Fixed trailing buffer distance in broker points maintained behind current market bid/ask price.
8. Notification Settings
- Notify_Group (Default: "=== NOTIFICATION ==="): Visual section separator for signal dispatch.
- Enable_Alert (Default: true): Displays native popup alert boxes inside the MetaTrader 5 terminal upon signal detection and trade placement.
- Enable_Sound (Default: true): Triggers an acoustic playback event when a trade condition occurs.
- Sound_File (Default: "alert2.wav"): File path of the audio asset located within the terminal Sounds folder.
- Enable_Push (Default: false): Forwards push notification alerts to registered mobile MetaTrader 5 clients via MetaQuotes ID.
- Enable_Email (Default: false): Dispatches email alerts to the recipient configured under Terminal Options -> Email tab.
- Email_Subject (Default: "RSI OB OS Signal"): Default header title applied to outbound email notifications.
9. Technical Confirmation Filters
Filter Mode & ADX Filter
- Mode_Group (Default: "=== FILTER MODE ==="): Visual section header for all secondary filtering mechanisms.
- ADX_Group (Default: "=== ADX FILTER ==="): Section separator for Average Directional Index settings.
- Use_ADX_Filter (Default: false): Activates trend strength filtering through the ADX indicator.
- ADX_Period (Default: 10): Calculation period for the ADX directional movement indicator.
- ADX_Min_Level (Default: 20.0): Minimum baseline ADX value required to authorize trade execution. Values below this threshold denote non-trending conditions.
Single Moving Average Filter
- MA_Group (Default: "=== SINGLE MA FILTER ==="): Section separator for Single Moving Average filter.
- Use_MA_Filter (Default: false): Enables trend alignment filtering via single moving average.
- MA_Period (Default: 50): Lookback period applied to calculate the moving average line.
- MA_Method (Default: MODE_SMA): Moving average calculation method (MODE_SMA, MODE_EMA, MODE_SMMA, MODE_LWMA).
- MA_Shift (Default: 0): Horizontal bar index displacement applied to the moving average series.
Ichimoku Kinko Hyo Filter
- Ichimoku_Group (Default: "=== ICHIMOKU SENKOU SPAN B FILTER ==="): Section separator for Ichimoku cloud baseline settings.
- Use_Ichimoku_Filter (Default: false): Activates structural filtering comparing closed price against Senkou Span B.
- Ichimoku_SenkouB (Default: 52): Calculation period for the Senkou Span B leading line.
- Ichimoku_Kijun (Default: 26): Calculation period for the Kijun-sen baseline.
RSI 75 Macro Trend Filter
- RSI75_Group (Default: "=== RSI 75 FILTER ==="): Section separator for long-period RSI trend evaluation.
- Use_RSI75_Filter (Default: false): Enables long-term momentum regime filtering using RSI 75.
- RSI_Filter_Period (Default: 75): Lookback period applied to the secondary RSI filter indicator.
Double Moving Average Filter
- DoubleMA_Group (Default: "=== DOUBLE MA FILTER ==="): Section separator for dual MA trend orientation.
- Use_DoubleMA_Filter (Default: false): Enables fast vs slow Moving Average directional filtering.
- MA_A_Period (Default: 75): Period for the faster moving average series.
- MA_A_Method (Default: MODE_EMA): Averaging calculation mode for the faster moving average.
- MA_A_Applied (Default: PRICE_CLOSE): Price constant used for the faster moving average calculation.
- MA_A_Shift (Default: 0): Bar shift applied to the faster moving average.
- MA_B_Period (Default: 140): Period for the slower moving average series.
- MA_B_Method (Default: MODE_EMA): Averaging calculation mode for the slower moving average.
- MA_B_Applied (Default: PRICE_CLOSE): Price constant used for the slower moving average calculation.
- MA_B_Shift (Default: 0): Bar shift applied to the slower moving average.
Awesome Oscillator Filter
- AO_Group (Default: "=== AWESOME OSCILLATOR FILTER ==="): Section separator for Awesome Oscillator momentum controls.
- Use_AO_Filter (Default: false): Master toggle enabling the Awesome Oscillator validation engine.
- Use_AO_Volume_Filter (Default: false): Enables minimum amplitude criteria on AO bar 1 value.
- AO_Buy_Min (Default: 4.0): Minimum positive value AO must register on bar 1 to validate Buy trades.
- AO_Sell_Max (Default: -4.0): Maximum negative value AO must register on bar 1 to validate Sell trades.
- Use_AO_Color_Filter (Default: false): Enforces color slope direction (AO[1] > AO[2] for Buy; AO[1] < AO[2] for Sell).
- Use_AO_Zero_Filter (Default: false): Enforces zero line crossing orientation combined with slope direction.
Parabolic SAR Filter
- SAR_Group (Default: "=== PARABOLIC SAR FILTER ==="): Section separator for Parabolic Stop and Reverse settings.
- Use_SAR_Filter (Default: false): Enables Parabolic SAR positioning filter.
- SAR_Step (Default: 0.02): Incremental acceleration factor step applied to SAR calculations.
- SAR_Maximum (Default: 0.2): Maximum allowable acceleration factor boundary for SAR calculations.
Heiken Ashi Filter
- HA_Group (Default: "=== HEIKEN ASHI FILTER ==="): Section separator for Heiken Ashi candlestick filtering.
- Use_HeikenAshi_Filter (Default: false): Enables candle color confirmation computed via synthetic Heiken Ashi open and close levels.
Commodity Channel Index (CCI) Filters
- CCI_Group (Default: "=== CCI TREND FILTER ==="): Section separator for standard CCI trend filter.
- Use_CCI_Filter (Default: false): Activates baseline zero-crossing filter using CCI.
- CCI_Period (Default: 50): Number of bars applied to the CCI trend calculation.
- CCI_Applied (Default: PRICE_CLOSE): Applied price array constant for CCI trend calculation.
- CCI_OBOS_Group (Default: "=== CCI OB & OS FILTER ==="): Section separator for cyclical extreme CCI filter.
- Use_CCI_OBOS_Filter (Default: false): Enables overbought and oversold validation using a separate CCI cycle.
- CCI_OBOS_Period (Default: 14): Calculation period applied to the cyclical CCI indicator.
- CCI_OBOS_Applied (Default: PRICE_CLOSE): Applied price array constant for cyclical CCI calculation.
- CCI_Overbought (Default: 100.0): Positive threshold upper boundary required to permit Buy execution.
- CCI_Oversold (Default: -100.0): Negative threshold lower boundary required to permit Sell execution.
Relative Vigor Index (RVI) Filters
- RVI_Group (Default: "=== RVI TREND FILTER ==="): Section separator for macro RVI zero-line evaluation.
- Use_RVI_Filter (Default: false): Activates zero-line direction verification through long-period RVI.
- RVI_Period (Default: 75): Calculation period for macro RVI trend evaluation.
- RVI_Signal_Group (Default: "=== RVI SIGNAL FILTER ==="): Section separator for dual-line RVI crossover filter.
- Use_RVI_Signal_Filter (Default: false): Enables crossover validation between RVI main and signal lines.
- RVI_Signal_Period (Default: 20): Calculation period for dual-line RVI crossover verification.
MACD Filters
- MACD_Group (Default: "=== MACD SIGNAL FILTER ==="): Section separator for MACD histogram momentum confirmation.
- Use_MACD_Filter (Default: false): Enables confirmation via MACD histogram sign (MACD Main minus MACD Signal).
- MACD_FastEMA (Default: 12): Averaging period for the fast exponential moving average in MACD.
- MACD_SlowEMA (Default: 26): Averaging period for the slow exponential moving average in MACD.
- MACD_SignalSMA (Default: 9): Averaging period for the signal simple moving average line in MACD.
- MACD_Applied (Default: PRICE_CLOSE): Applied price constant used for MACD derivation.
- MACD_Zero_Group (Default: "=== MACD LEV 0 FILTER ==="): Section separator for MACD baseline zero filter.
- Use_MACD_Zero_Filter (Default: false): Restricts Buy trades to positive MACD main line and Sell trades to negative MACD main line.
Support & Resistance Filter
- SR_Group (Default: "=== SUPPORT & RESISTANCE FILTER ==="): Section separator for horizontal level detection.
- Use_SR_Filter (Default: false): Enables structural support and resistance level proximity validation.
- SR_Period (Default: 50): Historical bar scan lookback depth utilized to isolate swing high and low extremes.
- SR_Zone_Points (Default: 80): Price tolerance bandwidth measured in broker points surrounding identified levels.
Fibonacci Retracement Filter
- Fib_Group (Default: "=== FIBONACCI FILTER ==="): Section separator for automated Fibonacci retracement filter.
- Use_Fib_Filter (Default: false): Enables swing-based Fibonacci zone entry validation.
- Fib_Level_1 (Default: 0.382): Inner ratio limit defining the target retracement band boundary.
- Fib_Level_2 (Default: 0.618): Outer ratio limit defining the target retracement band boundary.
- ZigZag_Depth (Default: 12): Depth parameter applied by the swing-point isolation algorithm.
- ZigZag_Deviation (Default: 5): Minimum deviation parameter in broker points required for inflection identification.
- ZigZag_Backstep (Default: 3): Minimum backward bar spacing separating consecutive swing vertices.
Operational Workflow and Installation
1. Attach the Expert Advisor to the preferred chart symbol and timeframe inside MetaTrader 5.
2. In the common tab, ensure the checkbox "Allow Algo Trading" is active.
3. Configure your risk model within the Inputs tab: select either Fixed_Lot or Use_Auto_Lot with appropriate reference balance scaling.
4. Set explicit Stop Loss and Take Profit protection modes (either fixed points or ATR-driven volatility buffers).
5. Activate preferred confirmation filters matching your technical strategy.
6. The EA operates exclusively on closed bar prices, ensuring that backtest results and live trade operations align with precision. All internal indicator handles are systematically released on deinitialization to maintain optimal platform memory performance.
Risk Disclaimer
Trading foreign exchange, commodities, cryptocurrencies, and derivative financial instruments involves significant exposure to capital risk and may not be suitable for all investors. High leverage can amplify losses as well as gains. Past technical performance or backtested metrics do not guarantee future performance. This Expert Advisor is a technical algorithmic software tool developed to assist in structured trade execution; it does not constitute financial or investment advice. Always thoroughly validate the operation of this software on a demo account under diverse market conditions prior to deployment on live trading accounts.
