OPEN-SOURCE SCRIPT

RShar Seasonal RSI

Seasonal RSI

This indicator, Seasonal RSI, is designed to enhance trading decisions by combining the **Relative Strength Index (RSI)** with insights derived from historical **seasonality patterns**. It not only calculates RSI but also overlays seasonality data for the current week of the year, providing traders with a more contextualized view of market conditions.

---

### **Key Features**

#### 1. **Relative Strength Index (RSI) Calculation**
- The script calculates the RSI for a user-defined period (`RSI Length`), which is an oscillator used to measure the speed and magnitude of price changes.
- RSI values are plotted on the chart, helping traders identify **overbought** and **oversold** conditions.
- Thresholds for **Overbought** and **Oversold** levels are customizable, with default values of 70 and 30, respectively.

---

#### 2. **Dynamic RSI Coloring Based on Seasonality**
- The color of the RSI line dynamically adjusts based on historical **win rates** for the current week of the year:
- **Bright Green** for win rates > 65%.
- **Green** for win rates between 50-65%.
- **Red** for win rates between 35-50%.
- **Dark Red** for win rates < 35%.
- This feature gives traders a quick visual cue about whether the historical performance of the current week tends to be bullish, neutral, or bearish.

---

#### 3. **Overbought and Oversold Level Visualization**
- Overbought and oversold levels are displayed as dotted horizontal lines on the RSI chart.
- These levels act as visual guides for potential price reversals:
- **Overbought (default 70)**: Indicates potential selling pressure.
- **Oversold (default 30)**: Indicates potential buying pressure.

---

#### 4. **Seasonality Data Integration**
- Historical **seasonality data** is used to analyze price performance patterns for each week of the year:
- **Win Rate**: The percentage of years in which prices closed higher during the current week.
- **Average Weekly Change**: The average price percentage change during the current week over historical data.
- This data provides additional context to RSI readings, helping traders align their strategies with seasonal tendencies.

---

#### 5. **Information Table Overlay**
- A table is displayed in the **top-right corner** of the chart, summarizing seasonality data for the current week:
- **Week Win Rate**: Displays the percentage of historical years where prices rose during this week.
- **Avg Weekly Change**: Shows the average percentage price change for the current week. Positive values are displayed in green, and negative values are shown in red.
- This overlay provides actionable insights without cluttering the chart.

---

### **How It Works**

1. **Seasonality Data**:
- A function (`getSeasonalityForWeek`) fetches or uses predefined mock seasonality data for each week of the year.
- For each week, it calculates:
- The **Win Rate** (percentage of years with positive performance).
- The **Mean Change** (average price percentage change).

2. **RSI Plot**:
- The RSI line is plotted on the chart.
- The line's color is determined by the win rate for the current week, providing a visual representation of historical performance trends.

3. **Threshold Visualization**:
- Horizontal lines for overbought and oversold levels are drawn to assist in identifying potential reversal points.

4. **Information Table**:
- The table summarizes the current week's seasonality data for quick reference, helping traders make data-driven decisions.

---

### **Use Cases**

- **Short-Term Traders**:
Use the dynamic RSI colors and seasonality table to align short-term trades with historical patterns of weekly performance.

- **Swing Traders**:
Identify whether a stock or market is in an overbought/oversold condition while considering the seasonal tendency for the week.

- **Contextual Decision-Making**:
Combine traditional RSI signals with historical data to reduce false signals and improve timing.

---

### **Limitations**
- The script uses **mock seasonality data** in its default state. To make it fully functional, replace the mock data with actual historical performance metrics for your specific ticker or market.
- The indicator does not fetch real-time external data due to Pine Script’s limitations, so all seasonality data must be manually updated or hardcoded.

---

This indicator provides a powerful way to combine technical analysis with historical trends, offering a unique edge to traders by adding seasonal context to RSI signals.
Relative Strength Index (RSI)Seasonalityseasonality-trading

Script de código aberto

No verdadeiro espírito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam compreendê-lo e analisá-lo. Parabéns ao autor! Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Quer usar esse script no gráfico?

Aviso legal