OPEN-SOURCE SCRIPT

Fibonacci - RSI Oscillator

1 899
Indicator Overview

The Fibonacci RSI Oscillator calculates the Relative Strength Index (RSI) based on a dynamically adjusting level derived from recent price action and a fixed Fibonacci ratio (0.236). This differs from standard RSI, which is calculated directly on the closing price. The objective is to measure momentum relative to a level that adapts to recent peaks and valleys.

Core Calculation Mechanism
Peak/Valley Tracking: The script identifies the highest high (state_peak) and lowest low (state_valley) since the last detected change in short-term directional bias (state_dir).
Dynamic Level Calculation: A level (state_dyn_level) is calculated using a fixed 0.236 Fibonacci ratio relative to the tracked peak and valley:
If bias is up: state_dyn_level = state_peak - (state_peak - state_valley) * 0.236
If bias is down: state_dyn_level = state_valley + (state_peak - state_valley) * 0.236
This level adjusts automatically when a new peak or valley is established in the current directional bias. If price crosses the dynamic level against the current bias, the bias flips, and the level recalculates.

Optional Source Smoothing: The calculated state_dyn_level can optionally be smoothed using a user-selected moving average (SMA, EMA, WMA, HMA, RMA) before the RSI calculation.
RSI Calculation: The standard RSI formula is applied to the (optionally smoothed) state_dyn_level series to produce the primary oscillator value (val_primary_osc).
Signal Line: A moving average (type and length configurable) is calculated on the val_primary_osc to generate the val_sig_line.
Key Features & Components
Dynamic Fibonacci Level: The core input for the RSI calculation, based on recent peaks/valleys and the 0.236 ratio.
Fibonacci Level RSI: The primary oscillator line representing the RSI of the dynamic level.
Signal Line: A moving average of the primary RSI line.
Overbought/Oversold Levels: User-defined threshold lines.
Optional Source Smoothing: Configurable MA smoothing applied to the dynamic level before RSI calculation.
Gradient RSI Color: Option to color the primary RSI line based on its value relative to OB/Mid/OS levels.
Zone & OB/OS Fills: Visual fills for the 0-50 / 50-100 zones and specific fills when the RSI enters OB/OS territory.
Background Gradient: Optional vertical background color gradient based on the RSI's position between 0 and 100.
Configurable Parameters: Inputs for lengths, MA types, OB/OS levels, colors, line widths, and feature toggles.
Visual Elements Explained

Fibonacci Level RSI Line: The main plotted oscillator (color/gradient/width configurable).
Signal Line: The moving average of the RSI line (color/width/MA type configurable).
OB/OS Lines: Horizontal lines plotted at the set OB/OS levels (color/width configurable).
Mid-Line (50): Horizontal line plotted at 50 (color/width configurable).

Zone Fills:
Background fill between 0-50 and 50-100 (colors configurable).
Conditional fill between the RSI line and the 50 line when RSI > OB level or RSI < OS level (colors configurable).
Background Gradient: Optional background coloring where transparency varies vertically with the RSI level (base colors and transparency range configurable).

Configuration Options
Users can adjust the following parameters in the indicator settings:
Smoothing: Enable/disable dynamic level smoothing; set length and MA type.
RSI: Set the RSI calculation length.
Signal Line: Set the signal line smoothing length and MA type.
Levels: Define Overbought and Oversold numeric thresholds.
Visuals: Configure colors and widths for the RSI line, signal line, OB/OS lines, mid-line, zone fills, and OB/OS fills.
Gradients: Enable/disable and configure colors for the RSI line gradient; enable/disable and configure colors/transparency for the background gradient.

Interpretation Notes
The oscillator reflects the momentum of the dynamic Fibonacci level, not directly the price. Divergences, OB/OS readings, and signal line crossovers should be interpreted in this context.
The behavior may differ from standard RSI, potentially offering a smoother output or highlighting different momentum patterns depending on market structure and volatility.
As with any indicator, signals should be used in conjunction with other analysis methods and risk management practices. It is not designed as a standalone trading system.

Risk Disclaimer:
Trading involves significant risk. This indicator is provided for analytical purposes only and does not constitute financial advice. Past performance is not indicative of future results. Use sound risk management practices and never trade with capital you cannot afford to lose.

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.