OPEN-SOURCE SCRIPT

RSI Bands

Overview

The RSI Bands indicator is a tool designed to calculate and display overbought, oversold, and middle bands based on the Relative Strength Index (RSI).

Its primary purpose is to provide traders with a clue on whether to place limit buy or limit sell orders, or to set stop-loss orders effectively. The bands represent the price levels the asset must reach for the RSI to align with specific thresholds:

Overbought Band: Displays the upper band representing the price level the asset must reach for the RSI to become overbought.

Oversold Band: Displays the lower band representing the price level the asset must reach for the RSI to become oversold.

Middle Band: Displays the middle band representing the price level the asset must reach for the RSI to hit the middle level. It uses both traditional RSI calculations and a dynamic period adjustment mechanism for improved adaptability to market conditions. The script also offers smoothing options for the bands.

Features
  • Calculates overbought, oversold, and middle bands using RSI values.
  • Dynamically adjusts the RSI period based on pivot points if enabled.
  • Offers smoothing options for the bands: EMA, SMA, or None.
  • Customizable input parameters for flexibility.


Inputs
  1. Source Value: Selects the data source (e.g., close price) for RSI calculation.
  2. Period: Sets the static RSI calculation period. Used if dynamic period is disabled.
  3. Use Dynamic Period?: Toggles the use of a dynamic RSI period.
  4. Pivot Left/Right Length: Determines the range of bars for pivot detection when using dynamic periods.
  5. Dynamic Period Multiplier: Scales the dynamically calculated RSI period.
  6. Overbought Level: RSI level that marks the overbought threshold.
  7. Oversold Level: RSI level that marks the oversold threshold.
  8. Middle Level: RSI level used as a midpoint reference.
  9. Smoothing Type: Specifies the smoothing method for the bands (EMA, SMA, or None).
  10. Smoothing Length: Length used for the selected smoothing method.


Key Calculations

RSI Calculation:

Computes RSI using gains and losses over the specified period (dynamic or static).

Incorporates a custom function for calculating RSI with dynamic periods.

Dynamic Period Adjustment:

Uses pivot points to determine an adaptive RSI period.

Multiplies the base dynamic period by the Dynamic Period Multiplier.

Band Calculation:

Calculates price changes (deltas) required to achieve the overbought, oversold, and middle RSI levels.

The price changes (deltas) are determined using an iterative approximation technique. For each target RSI level (overbought, oversold, or middle), the script estimates the required change in price by adjusting a hypothetical delta value until the calculated RSI aligns with the target RSI. This approximation ensures precise calculation of the price levels necessary for the RSI to reach the specified thresholds.

Computes the upper (overbought), lower (oversold), and middle bands by adding these deltas to the source price.

Smoothing:

Applies the selected smoothing method (EMA or SMA) to the calculated bands.

Plots
  • Overbought Band: Displays the upper band representing the price level the asset must reach for the RSI to become overbought.
  • Oversold Band: Displays the lower band representing the price level the asset must reach for the RSI to become oversold.
  • Middle Band: Displays the middle band representing the price level the asset must reach for the RSI to hit the middle level.


Usage
  1. Choose the source value (e.g., close price).
  2. Select whether to use a dynamic RSI period or a static one.
  3. Adjust pivot lengths and multipliers for dynamic period calculation as needed.
  4. Set the overbought, oversold, and middle RSI levels based on your analysis.
  5. Configure smoothing options for the bands.
  6. Observe the plotted bands and use them to identify potential overbought and oversold market conditions.

Bands and ChannelscrimsonvaultRelative Strength Index (RSI)

סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יוכלו להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אבל השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

רוצה להשתמש בסקריפ זה בגרף?

כתב ויתור