OPEN-SOURCE SCRIPT
Swing High/Low (Adaptive)

Swing High/Low (Adaptive)
Overview
The Indicator is a pivot point detection tool that identifies swing highs and lows with invalidation tracking. The key differentiator of this indicator is its adaptive invalidation system. Most pivot indicators simply mark every detected pivot without considering whether subsequent price action has made earlier pivots less relevant.
How It Works
The indicator uses Pine Script's native ta.pivotlow() and ta.pivothigh() functions combined with custom logic to detect swing points. The adaptive algorithm evaluates each potential pivot against the following criteria:
For Low Pivots:
For High Pivots:
This approach ensures that the indicator maintains clean swing structure and automatically adjusts when price action creates stronger pivots, providing a more realistic view of support and resistance levels.
Settings
Pivot Settings:
Pivot Display Settings:
Invalid Pivot Settings:
ZigZag Settings:
Use Cases
1. Market Structure Analysis
Identify key swing points to understand the current market structure and trend direction. The adaptive invalidation feature ensures you're always looking at the most relevant pivots.
2. Support and Resistance Identification
Use confirmed swing highs and lows as potential support and resistance levels for entry and exit planning.
3. Trend Confirmation
The ZigZag visualization helps confirm trends by showing the sequence of higher highs and higher lows (uptrend) or lower highs and lower lows (downtrend).
Disclaimer
This indicator is designed as a technical analysis tool and should be used in conjunction with other forms of analysis and proper risk management. Past performance does not guarantee future results, and traders should thoroughly test any strategy before implementing it with real capital.
Overview
The Indicator is a pivot point detection tool that identifies swing highs and lows with invalidation tracking. The key differentiator of this indicator is its adaptive invalidation system. Most pivot indicators simply mark every detected pivot without considering whether subsequent price action has made earlier pivots less relevant.
How It Works
The indicator uses Pine Script's native ta.pivotlow() and ta.pivothigh() functions combined with custom logic to detect swing points. The adaptive algorithm evaluates each potential pivot against the following criteria:
For Low Pivots:
- Confirms a new low pivot when it's the next expected pivot type in the swing sequence
- If consecutive lows occur, only accepts a new low if it's lower than the previous low
- Marks the previous low as invalidated when a stronger low is detected
For High Pivots:
- Confirms a new high pivot when it's the next expected pivot type in the swing sequence
- If consecutive highs occur, only accepts a new high if it's higher than the previous high
- Marks the previous high as invalidated when a stronger high is detected
This approach ensures that the indicator maintains clean swing structure and automatically adjusts when price action creates stronger pivots, providing a more realistic view of support and resistance levels.
Settings
Pivot Settings:
- Left Bars: Number of bars to the left required for pivot confirmation (default: 5)
- Right Bars: Number of bars to the right required for pivot confirmation (default: 5)
Pivot Display Settings:
- Toggle visibility for low and high pivots independently
- Customizable colors for valid pivot markers
- Low pivots marked with upward triangle (▲)
- High pivots marked with downward triangle (▼)
Invalid Pivot Settings:
- Optional display of invalidated pivots
- Separate color customization for invalid low and high pivots
- Helps visualize where market structure expectations changed
ZigZag Settings:
- Toggle ZigZag line display on/off
- Separate colors for upward and downward price swings
- Adjustable line width
Use Cases
1. Market Structure Analysis
Identify key swing points to understand the current market structure and trend direction. The adaptive invalidation feature ensures you're always looking at the most relevant pivots.
2. Support and Resistance Identification
Use confirmed swing highs and lows as potential support and resistance levels for entry and exit planning.
3. Trend Confirmation
The ZigZag visualization helps confirm trends by showing the sequence of higher highs and higher lows (uptrend) or lower highs and lower lows (downtrend).
Disclaimer
This indicator is designed as a technical analysis tool and should be used in conjunction with other forms of analysis and proper risk management. Past performance does not guarantee future results, and traders should thoroughly test any strategy before implementing it with real capital.
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。