OPEN-SOURCE SCRIPT

Relative Strength Index - RSI

51
🎯 Overview
This is an enhanced Relative Strength Index (RSI) indicator for TradingView that combines traditional RSI analysis with a moving average overlay to generate more reliable trading signals ⚡

🧩 Core Components
1. ⚙️ Indicator Settings

2. 🎛️ Input Parameters
A. 🎨 Color Settings:

5 different color themes: 🎨 Classic, 🚀 Modern, 💪 Robust, 🌈 Accented, ⚫⚪ Monochrome

Each theme provides distinct bullish/bearish color pairs

B. 📊 RSI Configuration:

📏 Length: Default 14 periods

📈 Source: Default close price (customizable)

📊 RSI MA Length: Default 365 periods

🔄 RSI MA Type: 6 options (EMA, SMA, RMA, WMA, VWMA, HMA)

C. 📢 Signal Display:

✅ Toggle for Bull/Bear crossover signals

📋 Table display showing current market bias

3. 🧮 Technical Calculations
A. 📈 RSI Calculation:

Standard RSI formula using ta.rsi()

Configurable source and period length

B. 📊 RSI Moving Average:

Customizable MA type applied to the RSI values

Serves as a dynamic signal line

Default 365-period EMA smooths long-term trends

C. 🔔 Signal Detection:

🟢 isBull_RSI: RSI > RSI_MA (bullish condition)

🔴 isBear_RSI: RSI < RSI_MA (bearish condition)

🟢 Bull: Crossover signal (RSI crosses above MA)

🔴 Bear: Crossunder signal (RSI crosses below MA)

4. 👁️ Visual Elements
A. 📉 Main Plots:

📊 RSI Line: Thick line (width 3) colored conditionally based on position relative to its MA

📈 RSI MA Line: Yellow line showing the smoothed RSI

🎯 50-Level Line: Dashed white reference line

B. 🎨 Fill Areas:

🟢 Overbought Zone : Filled between RSI and MA

🔴 Oversold Zone : Filled between RSI and MA

Colors vary based on selected theme

C. 🌈 Background Highlights:

Subtle background coloring on bullish/bearish crossover signals

D. 📋 Table Display:

Shows "⬆️ Bullish" or "⬇️ Bearish" with appropriate coloring

5. 🔔 Alert System
🟢 LONG Alert: Triggers when RSI > RSI_MA

🔴 SHORT Alert: Triggers when RSI < RSI_MA

Includes ticker symbol in alert message

🏁 Trading Logic
🎯 Primary Signals:
🟢 Bullish Setup:

📈 RSI crosses above its moving average

📊 RSI remains above MA (continuous bullish condition)

🎨 Visual: Green/theme bull colors, bullish fill areas

🔴 Bearish Setup:

📉 RSI crosses below its moving average

📊 RSI remains below MA (continuous bearish condition)

🎨 Visual: Red/theme bear colors, bearish fill areas

✨ Key Features:
📊 Trend Filter: The RSI MA (365-period) acts as a long-term trend filter

⚡ Momentum + Trend: Combines momentum (RSI) with trend (MA) for higher probability signals

👁️ Visual Clarity: Color-coded elements make market state immediately apparent

🛠️ Customizability: Multiple MA types and color schemes adapt to different trading styles

💻 Code Structure
The script is well-organized with clear sections:

🔧 MA function definition

⚙️ Input settings

🧮 Calculations

🎨 Color definitions

📊 Plotting

📋 Table display

🔔 Alert conditions

🎯 Best Use Cases
📈 Trend Following: In trending markets, signals align with the overall direction

🔄 Mean Reversion: In ranging markets, oversold/overbought fills indicate potential reversals

⏰ Multi-Timeframe Analysis: Works well on daily/weekly charts for long-term positioning

✅ Signal Confirmation: Can be combined with other indicators for entry/exit confirmation

🏆 Unique Advantages
🎯 Reduced Whipsaws: Long MA period (365) filters out noise

👁️ Clear Visual Hierarchy: Multiple visual layers convey information efficiently

💼 Professional Presentation: Clean, organized display suitable for sharing

🛠️ Flexible Configuration: Adaptable to different assets and timeframes

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.