OPEN-SOURCE SCRIPT

RSI Swing Indicator [future bot]

397
This Pine Script indicator is designed to identify and visualize price swings based on the Relative Strength Index (RSI). It draws swing lines and labels on the chart to highlight overbought and oversold conditions, as well as the structure of price movements (e.g., Higher Highs, Lower Lows). The indicator is useful for traders who want to track RSI-based price swings and identify potential trend reversals or continuations.
Key Features

RSI-Based Swing Detection:

The indicator uses RSI to detect overbought (above a user-defined threshold) and oversold (below a user-defined threshold) conditions.

It tracks price swings between these extremes, drawing lines and labels to visualize the swings.

Swing Lines:

Draws lines connecting oversold to overbought levels and vice versa.

Adjusts the lines dynamically as new extremes are reached.

Labels for Price Structure:

Labels are added to indicate the relationship between swings:

HH (Higher High): The current swing high is higher than the previous one.

LH (Lower High): The current swing high is lower than the previous one.

HL (Higher Low): The current swing low is higher than the previous one.

LL (Lower Low): The current swing low is lower than the previous one.

Dynamic Updates:

The indicator updates swing lines and labels in real-time as new price data comes in.

If the price moves deeper into overbought or oversold territory, the swing lines and labels adjust accordingly.

Input Parameters

RSI Source:

The price source for calculating RSI (default: close).

RSI Length:

The number of periods used to calculate RSI (default: 7).

RSI Overbought Level:

The threshold above which RSI is considered overbought (default: 70).

RSI Oversold Level:

The threshold below which RSI is considered oversold (default: 30).

How It Works

RSI Calculation:

The script calculates the RSI value based on the user-defined source and length.

State Detection:

The script tracks whether the RSI is in an overbought or oversold state.

Swing Detection:

When the RSI transitions from oversold to overbought (or vice versa), the script draws a new swing line and labels the swing.

If the price continues to move deeper into overbought or oversold territory, the swing lines and labels are updated to reflect the new extremes.

Labeling Price Structure:

The script compares the current swing high/low to the previous one and labels it as:

HH (Higher High) or LH (Lower High) for swing highs.

HL (Higher Low) or LL (Lower Low) for swing lows.

Visualization:

Swing lines are drawn between oversold and overbought levels.

Labels are placed above/below the price to indicate the swing structure.

Example Use Cases

Trend Identification:

Use the labels (HH, LH, HL, LL) to identify the overall trend structure.

For example, a series of HH and HL labels indicates an uptrend, while a series of LH and LL labels indicates a downtrend.

Reversal Signals:

Look for divergences between price and RSI swings to identify potential reversals.

For example, if the price makes a higher high (HH) but the RSI makes a lower high (LH), it could signal a bearish reversal.

Swing Trading:

Use the swing lines to identify potential entry and exit points based on RSI extreme

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.