OPEN-SOURCE SCRIPT

ZigZag Based RSI

308
Description
ZigZag Trend RSI (ZZ-RSI) is an advanced momentum indicator that combines ZigZag-based trend detection with a trend-adjusted RSI to deliver smarter overbought and oversold signals. Unlike traditional RSI that reacts purely to price movement, this indicator adapts its sensitivity based on the prevailing trend structure identified via the ZigZag pattern.

By dynamically adjusting RSI thresholds according to market direction, ZZ-RSI helps filter out false signals and aligns RSI readings with broader trend context—crucial for trend-following strategies, counter-trend entries, and volatility-based timing.

Core Components
ZigZag Pattern Recognition:
Identifies significant swing highs and lows based on price deviation (%) and pivot sensitivity (length). The most recent pivot determines the prevailing trend direction:

🟢 Bullish: last swing is a higher high

🔴 Bearish: last swing is a lower low

⚪ Neutral: no recent significant movement

Trend-Weighted RSI:
Modifies traditional RSI input by emphasizing price changes in the direction of the trend:

In bull trends, upside moves are magnified.

In bear trends, downside moves are emphasized.

Dynamic RSI Zones:

Overbought and Oversold thresholds adapt to the trend:

In uptrends: higher OB and slightly raised OS → tolerate stronger rallies

In downtrends: lower OS and slightly reduced OB → accommodate stronger sell-offs

In neutral: default OB/OS values apply

How to Use
✅ Entries (Reversal or Mean Reversion Traders):
Look for oversold signals (green triangle) in downtrends or neutrals to catch potential reversals.

Look for overbought signals (red triangle) in uptrends or neutrals to fade momentum.

Confirm with price action or volume for higher conviction.

📈 Trend Continuation (Momentum or Trend-Followers):
Use the trend direction label (Bullish / Bearish / Neutral) to align your trades with the broader move.

Combine with moving averages or price structure for entry timing.

Avoid counter-trend signals unless confirmed by divergence or exhaustion.

🧠 Signal Interpretation Table (top right of chart):
Trend: Indicates the current market direction.

RSI: Real-time trend-adjusted RSI value.

Signal: OB/OS/Neutral classification.

Customization Options
ZigZag Length / Deviation %:
Adjust pivot sensitivity and filter out minor noise.

RSI Length:
Controls how fast RSI responds to trend-adjusted price.

Color Settings:
Personalize visual cues for trend direction and OB/OS backgrounds.

Alerts Included
📢 Overbought/oversold conditions

🔄 Trend reversals (bullish or bearish shift)

These alerts are ideal for automated strategies, mobile notifications, or algorithmic workflows.

Ideal For
Traders seeking smarter RSI signals filtered by market structure

Trend-followers and swing traders looking for reliable reversals

Those frustrated with false OB/OS signals in volatile or trending markets

Best Practices
Use in confluence with price structure, trendlines, or S/R levels.

For intraday: consider lowering ZigZag Length and RSI Length.

For higher timeframes: use higher deviation % and smoother RSI to reduce noise.

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.