OPEN-SOURCE SCRIPT
Key Support and Resistance

KEY SUPPORT AND RESISTANCE - USER GUIDE
========================================
OVERVIEW
This indicator automatically identifies and displays key support and resistance levels based on swing highs and swing lows. It uses pivot point detection to mark significant price levels where the market has previously shown reactions, helping traders identify potential entry/exit points and key decision zones.
KEY FEATURES
• Automatic Level Detection: Identifies swing highs (resistance) and swing lows (support) using pivot point analysis
• Dynamic Line Management: Displays only recent levels within a specified lookback period to keep charts clean
• Auto-Extending Lines: Projects support/resistance levels forward to anticipate future price interactions
• Color-Coded Levels: Red lines for resistance, green lines for support for easy visual identification
========================================
PARAMETERS
========================================
Left Bars (Default: 10)
• Minimum: 5 bars
• Number of bars to the left of the pivot point
• Higher values = more significant levels but fewer signals
• Lower values = more sensitive detection but may include minor swings
Right Bars (Default: 10)
• Minimum: 5 bars
• Number of bars to the right of the pivot point
• Must be confirmed by price action before the level is drawn
• Balances between confirmation delay and signal accuracy
Show Last N Bars (Default: 200)
• Minimum: 10 bars
• Only displays support/resistance levels detected within the most recent N bars
• Keeps your chart clean by removing outdated levels
• Adjust based on your trading timeframe and style
Line Extension Length (Default: 48)
• Minimum: 1 bar
• How many bars forward the support/resistance lines extend
• Helps visualize potential future price interactions
• Longer extensions useful for swing trading, shorter for day trading
========================================
HOW TO USE
========================================
FOR SWING TRADERS
1. Use default settings (10/10) or increase to 15/15 for more significant levels
2. Set "Show Last N Bars" to 300-500 to capture longer-term levels
3. Look for price reactions when approaching these levels
4. Combine with volume analysis for confirmation
FOR DAY TRADERS
1. Consider reducing Left/Right Bars to 7-8 for more frequent signals
2. Set "Show Last N Bars" to 100-150 to focus on recent action
3. Reduce "Line Extension Length" to 20-30 bars
4. Watch for intraday bounces or breakouts at these levels
TRADING STRATEGIES
Bounce Trading (Mean Reversion)
• Enter long when price approaches green support lines
• Enter short when price approaches red resistance lines
• Use stop loss just beyond the support/resistance level
• Best in ranging or consolidating markets
Breakout Trading (Trend Following)
• Wait for price to break through resistance (bullish) or support (bearish)
• Confirm with increased volume
• Previous resistance becomes new support (and vice versa)
• Best in trending markets
Multi-Timeframe Analysis
• Check higher timeframe levels for major support/resistance zones
• Use lower timeframe levels for precise entry/exit timing
• Confluence of multiple timeframe levels creates strong zones
========================================
IMPORTANT NOTES
========================================
Line Confirmation Delay
• Lines appear with a delay equal to "Right Bars" parameter
• This delay ensures the pivot point is confirmed
• Real-time level detection requires price action confirmation
Chart Clarity
• Maximum 500 lines can be displayed (TradingView limitation)
• Adjust "Show Last N Bars" if chart becomes too cluttered
• Old lines automatically delete when outside the lookback period
False Signals
• Not all support/resistance levels will hold
• Use additional confirmation (volume, candlestick patterns, other indicators)
• Markets can break through levels, especially during high-impact news
BEST PRACTICES
1. Combine with Other Analysis: Use alongside trend indicators, volume, and price action patterns
2. Context Matters: Consider overall market trend and structure
3. Risk Management: Always use stop losses; don't rely solely on S/R levels
4. Market Conditions: More effective in liquid, actively traded markets
5. Backtesting: Test settings on your specific instrument and timeframe before live trading
TROUBLESHOOTING
Too Many Lines?
• Increase "Left Bars" and "Right Bars" values
• Decrease "Show Last N Bars" value
Too Few Lines?
• Decrease "Left Bars" and "Right Bars" values
• Increase "Show Last N Bars" value
Lines Not Appearing?
• Ensure sufficient price data is loaded on your chart
• Check that "Right Bars" have passed since the last swing point
• Verify indicator is properly loaded (refresh if needed)
TECHNICAL DETAILS
• Uses ta.pivothigh() and ta.pivotlow() functions for level detection
• Implements array-based line management for efficient rendering
• Automatic cleanup of outdated lines to maintain performance
• Overlay indicator - displays directly on price chart
Disclaimer: This indicator is for educational and informational purposes only. It does not constitute financial advice. Always conduct your own research and risk assessment before making trading decisions.
========================================
中文使用指南
========================================
概述
本指標自動識別並顯示基於波段高點和低點的關鍵支撐阻力位。使用樞軸點檢測標記市場先前反應的重要價格水平,幫助交易者識別潛在的進出場點和關鍵決策區域。
主要功能
• 自動水平檢測:使用樞軸點分析識別波段高點(阻力)和波段低點(支撐)
• 動態線條管理:僅顯示指定回看期內的近期水平,保持圖表清晰
• 自動延伸線條:將支撐阻力水平向前投影,預測未來價格互動
• 顏色編碼:紅線表示阻力,綠線表示支撐,便於視覺識別
========================================
參數說明
========================================
左側K棒數(預設:10)
• 最小值:5根K棒
• 樞軸點左側的K棒數量
• 數值越高 = 水平越重要但訊號越少
• 數值越低 = 檢測更敏感但可能包含次要波動
右側K棒數(預設:10)
• 最小值:5根K棒
• 樞軸點右側的K棒數量
• 必須經過價格行為確認後才繪製水平
• 在確認延遲和訊號準確性之間取得平衡
顯示最近N根K棒內的點(預設:200)
• 最小值:10根K棒
• 僅顯示最近N根K棒內檢測到的支撐阻力水平
• 透過移除過時水平保持圖表清晰
• 根據您的交易時間框架和風格調整
線條延伸長度(預設:48)
• 最小值:1根K棒
• 支撐阻力線向前延伸的K棒數
• 幫助視覺化潛在的未來價格互動
• 較長延伸適合波段交易,較短適合當沖交易
========================================
使用方法
========================================
波段交易者
1. 使用預設設定(10/10)或增加至15/15以獲得更重要的水平
2. 將「顯示最近N根K棒」設為300-500以捕捉長期水平
3. 觀察價格接近這些水平時的反應
4. 結合成交量分析進行確認
當沖交易者
1. 考慮將左右側K棒減少至7-8以獲得更頻繁的訊號
2. 將「顯示最近N根K棒」設為100-150以專注於近期行情
3. 將「線條延伸長度」減少至20-30根K棒
4. 觀察日內在這些水平的反彈或突破
交易策略
反彈交易(均值回歸)
• 當價格接近綠色支撐線時做多
• 當價格接近紅色阻力線時做空
• 在支撐阻力水平之外設置止損
• 在區間或盤整市場中效果最佳
突破交易(趨勢跟隨)
• 等待價格突破阻力(看漲)或支撐(看跌)
• 以增加的成交量確認
• 先前的阻力成為新的支撐(反之亦然)
• 在趨勢市場中效果最佳
多時間框架分析
• 檢查更高時間框架的主要支撐阻力區域
• 使用較低時間框架進行精確的進出場時機
• 多個時間框架水平的匯合創造強大區域
========================================
重要注意事項
========================================
線條確認延遲
• 線條出現時會有等於「右側K棒數」參數的延遲
• 此延遲確保樞軸點被確認
• 實時水平檢測需要價格行為確認
圖表清晰度
• 最多可顯示500條線(TradingView限制)
• 如果圖表變得太雜亂,請調整「顯示最近N根K棒」
• 超出回看期的舊線會自動刪除
假訊號
• 並非所有支撐阻力水平都會守住
• 使用額外確認(成交量、K棒型態、其他指標)
• 市場可能突破水平,特別是在重大新聞期間
最佳實踐
1. 結合其他分析:與趨勢指標、成交量和價格行為型態一起使用
2. 背景很重要:考慮整體市場趨勢和結構
3. 風險管理:始終使用止損;不要僅依賴支撐阻力水平
4. 市場條件:在流動性高、活躍交易的市場中更有效
5. 回測:在實盤交易前,在您的特定商品和時間框架上測試設定
故障排除
線條太多?
• 增加「左側K棒數」和「右側K棒數」數值
• 減少「顯示最近N根K棒」數值
線條太少?
• 減少「左側K棒數」和「右側K棒數」數值
• 增加「顯示最近N根K棒」數值
線條未出現?
• 確保圖表上載入了足夠的價格數據
• 檢查自上次波動點以來是否已過「右側K棒數」
• 驗證指標是否正確載入(如需要請刷新)
技術細節
• 使用 ta.pivothigh() 和 ta.pivotlow() 函數進行水平檢測
• 實施基於陣列的線條管理以實現高效渲染
• 自動清理過時線條以保持性能
• 疊加指標 - 直接顯示在價格圖表上
免責聲明:本指標僅供教育和資訊目的。不構成財務建議。在做出交易決策前,請務必進行自己的研究和風險評估。
========================================
OVERVIEW
This indicator automatically identifies and displays key support and resistance levels based on swing highs and swing lows. It uses pivot point detection to mark significant price levels where the market has previously shown reactions, helping traders identify potential entry/exit points and key decision zones.
KEY FEATURES
• Automatic Level Detection: Identifies swing highs (resistance) and swing lows (support) using pivot point analysis
• Dynamic Line Management: Displays only recent levels within a specified lookback period to keep charts clean
• Auto-Extending Lines: Projects support/resistance levels forward to anticipate future price interactions
• Color-Coded Levels: Red lines for resistance, green lines for support for easy visual identification
========================================
PARAMETERS
========================================
Left Bars (Default: 10)
• Minimum: 5 bars
• Number of bars to the left of the pivot point
• Higher values = more significant levels but fewer signals
• Lower values = more sensitive detection but may include minor swings
Right Bars (Default: 10)
• Minimum: 5 bars
• Number of bars to the right of the pivot point
• Must be confirmed by price action before the level is drawn
• Balances between confirmation delay and signal accuracy
Show Last N Bars (Default: 200)
• Minimum: 10 bars
• Only displays support/resistance levels detected within the most recent N bars
• Keeps your chart clean by removing outdated levels
• Adjust based on your trading timeframe and style
Line Extension Length (Default: 48)
• Minimum: 1 bar
• How many bars forward the support/resistance lines extend
• Helps visualize potential future price interactions
• Longer extensions useful for swing trading, shorter for day trading
========================================
HOW TO USE
========================================
FOR SWING TRADERS
1. Use default settings (10/10) or increase to 15/15 for more significant levels
2. Set "Show Last N Bars" to 300-500 to capture longer-term levels
3. Look for price reactions when approaching these levels
4. Combine with volume analysis for confirmation
FOR DAY TRADERS
1. Consider reducing Left/Right Bars to 7-8 for more frequent signals
2. Set "Show Last N Bars" to 100-150 to focus on recent action
3. Reduce "Line Extension Length" to 20-30 bars
4. Watch for intraday bounces or breakouts at these levels
TRADING STRATEGIES
Bounce Trading (Mean Reversion)
• Enter long when price approaches green support lines
• Enter short when price approaches red resistance lines
• Use stop loss just beyond the support/resistance level
• Best in ranging or consolidating markets
Breakout Trading (Trend Following)
• Wait for price to break through resistance (bullish) or support (bearish)
• Confirm with increased volume
• Previous resistance becomes new support (and vice versa)
• Best in trending markets
Multi-Timeframe Analysis
• Check higher timeframe levels for major support/resistance zones
• Use lower timeframe levels for precise entry/exit timing
• Confluence of multiple timeframe levels creates strong zones
========================================
IMPORTANT NOTES
========================================
Line Confirmation Delay
• Lines appear with a delay equal to "Right Bars" parameter
• This delay ensures the pivot point is confirmed
• Real-time level detection requires price action confirmation
Chart Clarity
• Maximum 500 lines can be displayed (TradingView limitation)
• Adjust "Show Last N Bars" if chart becomes too cluttered
• Old lines automatically delete when outside the lookback period
False Signals
• Not all support/resistance levels will hold
• Use additional confirmation (volume, candlestick patterns, other indicators)
• Markets can break through levels, especially during high-impact news
BEST PRACTICES
1. Combine with Other Analysis: Use alongside trend indicators, volume, and price action patterns
2. Context Matters: Consider overall market trend and structure
3. Risk Management: Always use stop losses; don't rely solely on S/R levels
4. Market Conditions: More effective in liquid, actively traded markets
5. Backtesting: Test settings on your specific instrument and timeframe before live trading
TROUBLESHOOTING
Too Many Lines?
• Increase "Left Bars" and "Right Bars" values
• Decrease "Show Last N Bars" value
Too Few Lines?
• Decrease "Left Bars" and "Right Bars" values
• Increase "Show Last N Bars" value
Lines Not Appearing?
• Ensure sufficient price data is loaded on your chart
• Check that "Right Bars" have passed since the last swing point
• Verify indicator is properly loaded (refresh if needed)
TECHNICAL DETAILS
• Uses ta.pivothigh() and ta.pivotlow() functions for level detection
• Implements array-based line management for efficient rendering
• Automatic cleanup of outdated lines to maintain performance
• Overlay indicator - displays directly on price chart
Disclaimer: This indicator is for educational and informational purposes only. It does not constitute financial advice. Always conduct your own research and risk assessment before making trading decisions.
========================================
中文使用指南
========================================
概述
本指標自動識別並顯示基於波段高點和低點的關鍵支撐阻力位。使用樞軸點檢測標記市場先前反應的重要價格水平,幫助交易者識別潛在的進出場點和關鍵決策區域。
主要功能
• 自動水平檢測:使用樞軸點分析識別波段高點(阻力)和波段低點(支撐)
• 動態線條管理:僅顯示指定回看期內的近期水平,保持圖表清晰
• 自動延伸線條:將支撐阻力水平向前投影,預測未來價格互動
• 顏色編碼:紅線表示阻力,綠線表示支撐,便於視覺識別
========================================
參數說明
========================================
左側K棒數(預設:10)
• 最小值:5根K棒
• 樞軸點左側的K棒數量
• 數值越高 = 水平越重要但訊號越少
• 數值越低 = 檢測更敏感但可能包含次要波動
右側K棒數(預設:10)
• 最小值:5根K棒
• 樞軸點右側的K棒數量
• 必須經過價格行為確認後才繪製水平
• 在確認延遲和訊號準確性之間取得平衡
顯示最近N根K棒內的點(預設:200)
• 最小值:10根K棒
• 僅顯示最近N根K棒內檢測到的支撐阻力水平
• 透過移除過時水平保持圖表清晰
• 根據您的交易時間框架和風格調整
線條延伸長度(預設:48)
• 最小值:1根K棒
• 支撐阻力線向前延伸的K棒數
• 幫助視覺化潛在的未來價格互動
• 較長延伸適合波段交易,較短適合當沖交易
========================================
使用方法
========================================
波段交易者
1. 使用預設設定(10/10)或增加至15/15以獲得更重要的水平
2. 將「顯示最近N根K棒」設為300-500以捕捉長期水平
3. 觀察價格接近這些水平時的反應
4. 結合成交量分析進行確認
當沖交易者
1. 考慮將左右側K棒減少至7-8以獲得更頻繁的訊號
2. 將「顯示最近N根K棒」設為100-150以專注於近期行情
3. 將「線條延伸長度」減少至20-30根K棒
4. 觀察日內在這些水平的反彈或突破
交易策略
反彈交易(均值回歸)
• 當價格接近綠色支撐線時做多
• 當價格接近紅色阻力線時做空
• 在支撐阻力水平之外設置止損
• 在區間或盤整市場中效果最佳
突破交易(趨勢跟隨)
• 等待價格突破阻力(看漲)或支撐(看跌)
• 以增加的成交量確認
• 先前的阻力成為新的支撐(反之亦然)
• 在趨勢市場中效果最佳
多時間框架分析
• 檢查更高時間框架的主要支撐阻力區域
• 使用較低時間框架進行精確的進出場時機
• 多個時間框架水平的匯合創造強大區域
========================================
重要注意事項
========================================
線條確認延遲
• 線條出現時會有等於「右側K棒數」參數的延遲
• 此延遲確保樞軸點被確認
• 實時水平檢測需要價格行為確認
圖表清晰度
• 最多可顯示500條線(TradingView限制)
• 如果圖表變得太雜亂,請調整「顯示最近N根K棒」
• 超出回看期的舊線會自動刪除
假訊號
• 並非所有支撐阻力水平都會守住
• 使用額外確認(成交量、K棒型態、其他指標)
• 市場可能突破水平,特別是在重大新聞期間
最佳實踐
1. 結合其他分析:與趨勢指標、成交量和價格行為型態一起使用
2. 背景很重要:考慮整體市場趨勢和結構
3. 風險管理:始終使用止損;不要僅依賴支撐阻力水平
4. 市場條件:在流動性高、活躍交易的市場中更有效
5. 回測:在實盤交易前,在您的特定商品和時間框架上測試設定
故障排除
線條太多?
• 增加「左側K棒數」和「右側K棒數」數值
• 減少「顯示最近N根K棒」數值
線條太少?
• 減少「左側K棒數」和「右側K棒數」數值
• 增加「顯示最近N根K棒」數值
線條未出現?
• 確保圖表上載入了足夠的價格數據
• 檢查自上次波動點以來是否已過「右側K棒數」
• 驗證指標是否正確載入(如需要請刷新)
技術細節
• 使用 ta.pivothigh() 和 ta.pivotlow() 函數進行水平檢測
• 實施基於陣列的線條管理以實現高效渲染
• 自動清理過時線條以保持性能
• 疊加指標 - 直接顯示在價格圖表上
免責聲明:本指標僅供教育和資訊目的。不構成財務建議。在做出交易決策前,請務必進行自己的研究和風險評估。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。