OPEN-SOURCE SCRIPT
MULTI-CONDITION RSI SIGNAL GENERATOR

═══════════════════════════════════════════════
MULTI-CONDITION RSI SIGNAL GENERATOR
═══════════════════════════════════════════════
OVERVIEW:
This indicator generates trading signals based on Relative Strength Index (RSI) movements with multiple confirmation layers designed to filter false signals and identify high-probability reversal opportunities.
═══════════════════════════════════════════════
WHAT MAKES THIS ORIGINAL:
═══════════════════════════════════════════════
Unlike basic RSI indicators that simply plot overbought/oversold crossovers, this system combines FOUR distinct confirmation mechanisms:
1. PERSISTENCE FILTERING - Requires RSI to remain in extreme zones for a minimum duration
2. LOOKBACK VALIDATION - Verifies recent extreme zone visits before signaling
3. DIVERGENCE DETECTION - Identifies price/RSI divergence for stronger signals
4. MOMENTUM CONFIRMATION - Provides trend-continuation entries via midline crosses
This multi-layered approach significantly reduces whipsaw trades that plague simple RSI crossover systems.
═══════════════════════════════════════════════
HOW IT WORKS (TECHNICAL METHODOLOGY):
═══════════════════════════════════════════════
STEP 1: RSI CALCULATION
- Standard RSI calculation using user-defined period (default: 14)
- Monitors two extreme zones: Overbought (default: 70) and Oversold (default: 30)
STEP 2: PERSISTENCE FILTERING
The script counts how many bars RSI has spent in extreme zones within the lookback period:
- For overbought signals: Counts bars where RSI > 70
- For oversold signals: Counts bars where RSI < 30
- Signal only triggers if count >= Minimum Duration (default: 4 bars)
This filters out brief spikes that immediately reverse, focusing on sustained extreme conditions that are more likely to lead to genuine reversals.
STEP 3: LOOKBACK VALIDATION
- Checks if RSI reached extreme zones within the Lookback Bars period (default: 20)
- Uses ta.highest() and ta.lowest() functions to verify recent extremes
- Ensures we're trading reversals from meaningful extremes, not random crossovers
STEP 4: BASIC SIGNAL GENERATION
- BUY SIGNAL: RSI crosses above the oversold level (30) after meeting persistence and lookback conditions
- SELL SIGNAL: RSI crosses below the overbought level (70) after meeting persistence and lookback conditions
STEP 5: DIVERGENCE DETECTION
The script identifies two types of divergence over the Divergence Lookback period (default: 5 bars):
A) BULLISH DIVERGENCE (indicates potential upward reversal):
- Price makes a lower low (current low < previous low)
- RSI makes a higher low (current RSI low > previous RSI low)
- Suggests weakening downward momentum
B) BEARISH DIVERGENCE (indicates potential downward reversal):
- Price makes a higher high (current high > previous high)
- RSI makes a lower high (current RSI high < previous RSI high)
- Suggests weakening upward momentum
STEP 6: STRONG SIGNAL CONFIRMATION
- STRONG BUY: Basic buy signal + bullish divergence present
- STRONG SELL: Basic sell signal + bearish divergence present
- These represent the highest-probability setups
STEP 7: MOMENTUM SIGNALS (OPTIONAL)
- MOMENTUM BUY: RSI crosses above 50 after being oversold (trend continuation)
- MOMENTUM SELL: RSI crosses below 50 after being overbought (trend continuation)
- Smaller signals for traders who want trend-following entries
═══════════════════════════════════════════════
SIGNAL TYPES AND VISUAL INDICATORS:
═══════════════════════════════════════════════
📈 GREEN TRIANGLE (below bar) - Standard Buy Signal
RSI crossed above oversold level with confirmation filters
📉 RED TRIANGLE (above bar) - Standard Sell Signal
RSI crossed below overbought level with confirmation filters
🔵 BLUE TRIANGLE (below bar) - Strong Buy Signal
Buy signal + bullish divergence (HIGHEST PRIORITY)
🟣 PURPLE TRIANGLE (above bar) - Strong Sell Signal
Sell signal + bearish divergence (HIGHEST PRIORITY)
🟢 GREEN CIRCLE (small) - Momentum Buy
RSI crosses above 50 after oversold conditions
🔴 RED CIRCLE (small) - Momentum Sell
RSI crosses below 50 after overbought conditions
BACKGROUND SHADING:
- Light red background: RSI currently overbought
- Light green background: RSI currently oversold
═══════════════════════════════════════════════
PARAMETER SETTINGS:
═══════════════════════════════════════════════
1. OVERBOUGHT LEVEL (default: 70, range: 50-90)
- Higher values = fewer but stronger overbought signals
- Lower values = more sensitive to overbought conditions
- Recommended: 70 for standard markets, 80 for crypto/volatile assets
2. OVERSOLD LEVEL (default: 30, range: 10-50)
- Lower values = fewer but stronger oversold signals
- Higher values = more sensitive to oversold conditions
- Recommended: 30 for standard markets, 20 for crypto/volatile assets
3. RSI PERIOD (default: 14, range: 2-50)
- Standard RSI calculation period
- Lower = more sensitive/faster signals
- Higher = smoother/slower signals
- Recommended: 14 (industry standard)
4. MINIMUM DURATION (default: 4, range: 1-20)
- Required bars in extreme zone before signal
- Higher values = fewer signals but better quality
- Lower values = more signals but more false positives
- Recommended: 3-5 for day trading, 5-10 for swing trading
5. LOOKBACK BARS (default: 20, range: 5-100)
- How far back to check for extreme zone visits
- Should match your typical trading timeframe
- Recommended: 20 for intraday, 50 for daily charts
6. DIVERGENCE LOOKBACK (default: 5, range: 2-20)
- Period for comparing price/RSI highs and lows
- Lower values = more frequent divergence signals
- Higher values = more significant divergences
- Recommended: 5-10 depending on timeframe
═══════════════════════════════════════════════
HOW TO USE THIS INDICATOR:
═══════════════════════════════════════════════
RECOMMENDED TRADING APPROACH:
1. PRIMARY ENTRIES: Focus on Strong Buy/Sell signals (blue/purple triangles)
- These have the highest win rate due to divergence confirmation
- Wait for price action confirmation (support/resistance, candlestick patterns)
2. SECONDARY ENTRIES: Regular Buy/Sell signals (green/red triangles)
- Use these when Strong signals are infrequent
- Require additional confirmation from other indicators or chart patterns
3. TREND CONTINUATION: Momentum signals (small circles)
- Best used when overall trend is clear
- Not recommended for reversal trading
4. FILTER TRADES: Use background shading as context
- Be cautious entering longs when background is red (overbought)
- Be cautious entering shorts when background is green (oversold)
RISK MANAGEMENT GUIDELINES:
- Never risk more than 2-5% of capital per trade
- Use stop losses below recent swing lows (buys) or above swing highs (sells)
- Target at least 1.5:1 reward-to-risk ratio
- Consider position sizing based on signal strength
TIMEFRAME RECOMMENDATIONS:
- 15min - 1hour: Day trading with adjusted parameters (lower minimum duration)
- 4hour - Daily: Swing trading with default parameters
- Weekly: Position trading with increased lookback periods
COMPLEMENTARY TOOLS:
This indicator works best when combined with:
- Support and resistance levels
- Trend indicators (moving averages, trend lines)
- Volume analysis
- Price action patterns (engulfing candles, pin bars)
═══════════════════════════════════════════════
LIMITATIONS AND CONSIDERATIONS:
═══════════════════════════════════════════════
- This is NOT a standalone trading system - requires additional analysis
- RSI-based strategies perform best in ranging/choppy markets
- May generate fewer signals in strong trending markets
- Divergence signals can be early - wait for price confirmation
- Not recommended for highly illiquid assets
- Backtest on your specific market before live trading
- No indicator is 100% accurate - always use proper risk management
═══════════════════════════════════════════════
TECHNICAL NOTES:
═══════════════════════════════════════════════
- Code is original and does not reuse external libraries
- Uses Pine Script v5 native functions only
- Alert conditions included for all signal types
- No repainting - signals appear and remain fixed
- Efficient calculation methods minimize processing load
═══════════════════════════════════════════════
ALERT SETUP:
═══════════════════════════════════════════════
Four alert conditions are available:
1. "Buy Alert" - Triggers on standard buy signals
2. "Sell Alert" - Triggers on standard sell signals
3. "Strong Buy Alert" - Triggers on divergence-confirmed buy signals
4. "Strong Sell Alert" - Triggers on divergence-confirmed sell signals
To set up alerts: Right-click chart → Add Alert → Select desired condition
═══════════════════════════════════════════════
This indicator is provided for educational and informational purposes. Always practice proper risk management and never trade with money you cannot afford to lose.
MULTI-CONDITION RSI SIGNAL GENERATOR
═══════════════════════════════════════════════
OVERVIEW:
This indicator generates trading signals based on Relative Strength Index (RSI) movements with multiple confirmation layers designed to filter false signals and identify high-probability reversal opportunities.
═══════════════════════════════════════════════
WHAT MAKES THIS ORIGINAL:
═══════════════════════════════════════════════
Unlike basic RSI indicators that simply plot overbought/oversold crossovers, this system combines FOUR distinct confirmation mechanisms:
1. PERSISTENCE FILTERING - Requires RSI to remain in extreme zones for a minimum duration
2. LOOKBACK VALIDATION - Verifies recent extreme zone visits before signaling
3. DIVERGENCE DETECTION - Identifies price/RSI divergence for stronger signals
4. MOMENTUM CONFIRMATION - Provides trend-continuation entries via midline crosses
This multi-layered approach significantly reduces whipsaw trades that plague simple RSI crossover systems.
═══════════════════════════════════════════════
HOW IT WORKS (TECHNICAL METHODOLOGY):
═══════════════════════════════════════════════
STEP 1: RSI CALCULATION
- Standard RSI calculation using user-defined period (default: 14)
- Monitors two extreme zones: Overbought (default: 70) and Oversold (default: 30)
STEP 2: PERSISTENCE FILTERING
The script counts how many bars RSI has spent in extreme zones within the lookback period:
- For overbought signals: Counts bars where RSI > 70
- For oversold signals: Counts bars where RSI < 30
- Signal only triggers if count >= Minimum Duration (default: 4 bars)
This filters out brief spikes that immediately reverse, focusing on sustained extreme conditions that are more likely to lead to genuine reversals.
STEP 3: LOOKBACK VALIDATION
- Checks if RSI reached extreme zones within the Lookback Bars period (default: 20)
- Uses ta.highest() and ta.lowest() functions to verify recent extremes
- Ensures we're trading reversals from meaningful extremes, not random crossovers
STEP 4: BASIC SIGNAL GENERATION
- BUY SIGNAL: RSI crosses above the oversold level (30) after meeting persistence and lookback conditions
- SELL SIGNAL: RSI crosses below the overbought level (70) after meeting persistence and lookback conditions
STEP 5: DIVERGENCE DETECTION
The script identifies two types of divergence over the Divergence Lookback period (default: 5 bars):
A) BULLISH DIVERGENCE (indicates potential upward reversal):
- Price makes a lower low (current low < previous low)
- RSI makes a higher low (current RSI low > previous RSI low)
- Suggests weakening downward momentum
B) BEARISH DIVERGENCE (indicates potential downward reversal):
- Price makes a higher high (current high > previous high)
- RSI makes a lower high (current RSI high < previous RSI high)
- Suggests weakening upward momentum
STEP 6: STRONG SIGNAL CONFIRMATION
- STRONG BUY: Basic buy signal + bullish divergence present
- STRONG SELL: Basic sell signal + bearish divergence present
- These represent the highest-probability setups
STEP 7: MOMENTUM SIGNALS (OPTIONAL)
- MOMENTUM BUY: RSI crosses above 50 after being oversold (trend continuation)
- MOMENTUM SELL: RSI crosses below 50 after being overbought (trend continuation)
- Smaller signals for traders who want trend-following entries
═══════════════════════════════════════════════
SIGNAL TYPES AND VISUAL INDICATORS:
═══════════════════════════════════════════════
📈 GREEN TRIANGLE (below bar) - Standard Buy Signal
RSI crossed above oversold level with confirmation filters
📉 RED TRIANGLE (above bar) - Standard Sell Signal
RSI crossed below overbought level with confirmation filters
🔵 BLUE TRIANGLE (below bar) - Strong Buy Signal
Buy signal + bullish divergence (HIGHEST PRIORITY)
🟣 PURPLE TRIANGLE (above bar) - Strong Sell Signal
Sell signal + bearish divergence (HIGHEST PRIORITY)
🟢 GREEN CIRCLE (small) - Momentum Buy
RSI crosses above 50 after oversold conditions
🔴 RED CIRCLE (small) - Momentum Sell
RSI crosses below 50 after overbought conditions
BACKGROUND SHADING:
- Light red background: RSI currently overbought
- Light green background: RSI currently oversold
═══════════════════════════════════════════════
PARAMETER SETTINGS:
═══════════════════════════════════════════════
1. OVERBOUGHT LEVEL (default: 70, range: 50-90)
- Higher values = fewer but stronger overbought signals
- Lower values = more sensitive to overbought conditions
- Recommended: 70 for standard markets, 80 for crypto/volatile assets
2. OVERSOLD LEVEL (default: 30, range: 10-50)
- Lower values = fewer but stronger oversold signals
- Higher values = more sensitive to oversold conditions
- Recommended: 30 for standard markets, 20 for crypto/volatile assets
3. RSI PERIOD (default: 14, range: 2-50)
- Standard RSI calculation period
- Lower = more sensitive/faster signals
- Higher = smoother/slower signals
- Recommended: 14 (industry standard)
4. MINIMUM DURATION (default: 4, range: 1-20)
- Required bars in extreme zone before signal
- Higher values = fewer signals but better quality
- Lower values = more signals but more false positives
- Recommended: 3-5 for day trading, 5-10 for swing trading
5. LOOKBACK BARS (default: 20, range: 5-100)
- How far back to check for extreme zone visits
- Should match your typical trading timeframe
- Recommended: 20 for intraday, 50 for daily charts
6. DIVERGENCE LOOKBACK (default: 5, range: 2-20)
- Period for comparing price/RSI highs and lows
- Lower values = more frequent divergence signals
- Higher values = more significant divergences
- Recommended: 5-10 depending on timeframe
═══════════════════════════════════════════════
HOW TO USE THIS INDICATOR:
═══════════════════════════════════════════════
RECOMMENDED TRADING APPROACH:
1. PRIMARY ENTRIES: Focus on Strong Buy/Sell signals (blue/purple triangles)
- These have the highest win rate due to divergence confirmation
- Wait for price action confirmation (support/resistance, candlestick patterns)
2. SECONDARY ENTRIES: Regular Buy/Sell signals (green/red triangles)
- Use these when Strong signals are infrequent
- Require additional confirmation from other indicators or chart patterns
3. TREND CONTINUATION: Momentum signals (small circles)
- Best used when overall trend is clear
- Not recommended for reversal trading
4. FILTER TRADES: Use background shading as context
- Be cautious entering longs when background is red (overbought)
- Be cautious entering shorts when background is green (oversold)
RISK MANAGEMENT GUIDELINES:
- Never risk more than 2-5% of capital per trade
- Use stop losses below recent swing lows (buys) or above swing highs (sells)
- Target at least 1.5:1 reward-to-risk ratio
- Consider position sizing based on signal strength
TIMEFRAME RECOMMENDATIONS:
- 15min - 1hour: Day trading with adjusted parameters (lower minimum duration)
- 4hour - Daily: Swing trading with default parameters
- Weekly: Position trading with increased lookback periods
COMPLEMENTARY TOOLS:
This indicator works best when combined with:
- Support and resistance levels
- Trend indicators (moving averages, trend lines)
- Volume analysis
- Price action patterns (engulfing candles, pin bars)
═══════════════════════════════════════════════
LIMITATIONS AND CONSIDERATIONS:
═══════════════════════════════════════════════
- This is NOT a standalone trading system - requires additional analysis
- RSI-based strategies perform best in ranging/choppy markets
- May generate fewer signals in strong trending markets
- Divergence signals can be early - wait for price confirmation
- Not recommended for highly illiquid assets
- Backtest on your specific market before live trading
- No indicator is 100% accurate - always use proper risk management
═══════════════════════════════════════════════
TECHNICAL NOTES:
═══════════════════════════════════════════════
- Code is original and does not reuse external libraries
- Uses Pine Script v5 native functions only
- Alert conditions included for all signal types
- No repainting - signals appear and remain fixed
- Efficient calculation methods minimize processing load
═══════════════════════════════════════════════
ALERT SETUP:
═══════════════════════════════════════════════
Four alert conditions are available:
1. "Buy Alert" - Triggers on standard buy signals
2. "Sell Alert" - Triggers on standard sell signals
3. "Strong Buy Alert" - Triggers on divergence-confirmed buy signals
4. "Strong Sell Alert" - Triggers on divergence-confirmed sell signals
To set up alerts: Right-click chart → Add Alert → Select desired condition
═══════════════════════════════════════════════
This indicator is provided for educational and informational purposes. Always practice proper risk management and never trade with money you cannot afford to lose.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้มันเป็นโอเพ่นซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันการทำงานของสคริปต์ได้ ขอแสดงความชื่นชมผู้เขียน! แม้ว่าคุณจะสามารถใช้งานได้ฟรี แต่อย่าลืมว่าการเผยแพร่โค้ดซ้ำนั้นจะต้องเป็นไปตามกฎระเบียบการใช้งานของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้มันเป็นโอเพ่นซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันการทำงานของสคริปต์ได้ ขอแสดงความชื่นชมผู้เขียน! แม้ว่าคุณจะสามารถใช้งานได้ฟรี แต่อย่าลืมว่าการเผยแพร่โค้ดซ้ำนั้นจะต้องเป็นไปตามกฎระเบียบการใช้งานของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ ข้อกำหนดการใช้งาน