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에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.