The RSIDivergence for Pair Trading
- Индикаторы
- Ledi Haryadi
- Версия: 1.421
- Активации: 5
The RSIDivergence is a custom indicator for the MetaTrader 4 (MT4) platform, designed to analyze the divergence between the Relative Strength Index (RSI) values of two currency pairs. It compares the RSI of the chart’s symbol (first symbol) with a user-defined second symbol, displaying both RSI values and their absolute difference (divergence) in a separate subwindow. The indicator provides visual and alert-based feedback to highlight significant divergence levels, with customizable settings for flexibility.
Key Features
- RSI Calculation:
- Computes RSI for the chart’s symbol (e.g., EURUSD) and a user-defined second symbol (default: USDCHF) using a configurable period (default: 8).
- Supports inversion of RSI values for either symbol (default: disabled), allowing users to reverse the RSI calculation (100 - RSI) for specific analysis needs.
- Divergence Measurement:
- Calculates the absolute difference between the RSI values of the two symbols, plotted as a dotted line in the subwindow.
- Displays the current divergence percentage in a label within the subwindow, updated in real-time.
- Visualization:
- Plots RSI for the first symbol (default color: aqua) and second symbol (default color: red) as solid lines in a subwindow, scaled from 0 to 100.
- Shows divergence as a dotted line (default color: yellow) in the same subwindow.
- Includes RSI levels at 10, 30, 70, and 90 for reference, with a customizable label for divergence display (position, font size, and color adjustable).
- Alerts and Notifications:
- Triggers alerts when divergence exceeds a user-defined threshold (default: 80%), with options for pop-up alerts (default: enabled) and push notifications (default: disabled).
- Prevents repeated alerts on the same bar using timestamp tracking, ensuring one alert per bar.
- Alert messages include the symbols, divergence percentage, threshold, and timestamp.
- Customization:
- Offers input parameters to adjust the second symbol, RSI period, inversion settings, colors (for RSI lines, divergence line, and label), label position (X, Y coordinates), font size, and alert settings.
- Allows users to enable/disable alerts and notifications based on their preferences.
Usage
- Initialization: Validates the second symbol in Market Watch, accounting for any suffix (e.g., ".m" or ".pro"). Sets up three buffers for RSI and divergence, creates a divergence label, and configures the subwindow with a custom name.
- Operation: Calculates RSI for both symbols and their divergence for each bar, updating the subwindow plots and divergence label. Checks for divergence exceeding the threshold and triggers alerts if enabled.
- Visualization: Displays RSI lines, divergence line, and a label showing the current divergence percentage in the subwindow, with customizable colors and positions.
- Deinitialization: Removes all indicator objects (labels) from the subwindow upon removal.
Notes
- Requires the second symbol to be available in Market Watch, with automatic suffix detection for compatibility.
- Operates on the current chart’s timeframe, processing bars efficiently based on the RSI period.
- The indicator focuses solely on RSI divergence, without additional technical indicators or risk management features.
