OPEN-SOURCE SCRIPT

RSI Divergence Candlestick SwiftEdge

243
// RSI Divergence Candlestick SwiftEdge
//
// Overview:
// RSI Divergence Candlestick SwiftEdge is a unique oscillator that transforms the traditional Relative Strength Index (RSI) into a candlestick format, combined with advanced divergence detection. This indicator is designed to help traders identify momentum shifts and potential reversals by visualizing RSI as candlesticks and highlighting both regular and hidden divergences between price and RSI. Unlike standard RSI indicators, this tool provides a more intuitive, price-like representation of RSI movements, making it easier to spot trends and reversals in momentum.
//
// Why This Combination?
// The combination of RSI candlesticks and divergence detection serves a dual purpose:
// 1. RSI Candlesticks: By presenting RSI as candlesticks, traders can apply familiar price action techniques (such as identifying trends, reversals, or consolidation patterns) directly to RSI. This format makes it easier to see momentum shifts in a way that resembles price movements.
// 2. Divergence Detection: Regular and hidden divergences between price and RSI often signal potential reversals or trend continuations. This indicator automatically identifies these divergences and draws lines to connect the pivot points, helping traders spot high-probability setups without manual analysis.
//
// How It Works:
// - RSI Candlesticks: The indicator calculates the RSI using a user-defined length (default 14). Each candlestick is constructed as follows:
// * Open: The RSI value from the previous bar.
// * Close: The current RSI value.
// * High/Low: Estimated by looking at the highest and lowest RSI values over a short lookback period (default 3 bars), simulating wicks to mimic price candlestick behavior.
// The candlesticks are colored green for upward momentum (close > open) and red for downward momentum (close < open), with gray wicks for clarity.
// - Divergence Detection: The indicator identifies pivot highs and lows in both price and RSI using a pivot lookback period (default 5 bars). It then checks for four types of divergences:
// * Regular Bullish Divergence: Price makes a lower low, but RSI makes a higher low, indicating potential reversal to the upside.
// * Regular Bearish Divergence: Price makes a higher high, but RSI makes a lower high, indicating potential reversal to the downside.
// * Hidden Bullish Divergence: Price makes a higher low, but RSI makes a lower low, suggesting trend continuation to the upside.
// * Hidden Bearish Divergence: Price makes a lower high, but RSI makes a higher high, suggesting trend continuation to the downside.
// Divergence lines are drawn between the RSI pivot points in the oscillator window and optionally on the price chart. Regular divergences use solid lines, while hidden divergences use dashed lines, with green for bullish and red for bearish signals.
// - Overbought/Oversold Restriction: By default, divergences are restricted to overbought (RSI > 70) or oversold (RSI < 30) zones to filter out less reliable signals. This can be disabled in the settings.
//
// How to Use:
// 1. Add the indicator to your chart to see RSI displayed as candlesticks in the oscillator window.
// 2. Look for RSI candlestick patterns:
// * Green candlesticks indicate increasing momentum; red candlesticks indicate decreasing momentum.
// * Use the wicks to identify overextensions in momentum, similar to price candlesticks.
// 3. Identify divergences:
// * Regular bullish/bearish divergences (solid lines) may signal reversals.
// * Hidden bullish/bearish divergences (dashed lines) may signal trend continuations.
// * Divergence lines are drawn in the RSI window and optionally on the price chart (toggle in settings).
// 4. Adjust settings:
// * RSI Length (default 14): Controls the sensitivity of the RSI calculation.
// * Wick Lookback (default 3): Determines how far back to look for RSI highs/lows to create wicks.
// * Pivot Lookback (default 5): Controls the sensitivity of pivot point detection for divergence.
// * Restrict Divergence (default true): Limits divergences to overbought/oversold zones.
// * Show Divergence on Chart (default true): Toggles whether divergence lines appear on the price chart.
//
// Use Case:
// This indicator is ideal for swing traders and reversal hunters looking to combine momentum analysis with price action techniques. The RSI candlestick format allows traders to apply chart patterns directly to RSI, while the divergence detection highlights high-probability setups. For example, a regular bullish divergence in an oversold zone, combined with a bullish RSI candlestick pattern, can signal a strong buying opportunity.
//
// Limitations:
// - The wicks on RSI candlesticks are an estimation based on recent RSI values, as Pine Script cannot access intra-bar RSI data.
// - Divergence detection relies on pivot points, which may lag slightly due to the lookback period. Adjust the pivot lookback setting to balance sensitivity and reliability.
// - This is an indicator, not a strategy, so it does not provide backtesting results or trade signals. Use it as part of a broader trading system.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.