OPEN-SOURCE SCRIPT
Classic Pattern Engine

Is a chart-pattern detection tool built around confirmed swing pivots.
The script identifies selected classic chart-pattern structures and draws them directly on the chart. It is designed as a visual pattern-mapping tool, not as an automated trading system.
What the script detects
Reversal patterns:
- Double Top
- Double Bottom
- Triple Top
- Triple Bottom
- Head and Shoulders
- Inverted Head and Shoulders
Continuation / structure patterns:
- Rectangles
- Ascending Triangle
- Descending Triangle
- Symmetrical Triangle
- Rising Wedge
- Falling Wedge
- Bull Flag
- Bear Flag
- Bullish Pennant
- Bearish Pennant
How it works
The script uses confirmed pivot highs and pivot lows to build a swing structure. It then compares the most recent confirmed swings against geometric conditions such as:
- Similarity of highs or lows
- Pattern height relative to ATR
- Slope of upper and lower boundaries
- Convergence or parallel behavior
- Pattern duration
- Flag or pennant context when applicable
Each detected pattern receives a quality score. This score is based on the geometry of the pattern, such as symmetry, height, similarity of key swing points, slope behavior, and structure fit. The score is intended to help users filter weaker shapes from cleaner structures.
Entry, Stop, and Target levels
The script can display Entry, Stop, and Target reference levels for detected patterns.
These levels are geometric references derived from the detected pattern structure. They are not trade recommendations.
The script can also track the state of the detected setup:
- Pending: the pattern is detected but entry has not been triggered
- Active: entry level has been reached
- Target Hit: price reached the target reference level
- Stop Hit: price reached the stop reference level
- Expired: the setup remained unresolved beyond the selected time window
The Entry label can also show an estimated R:R value based on the distance between Entry, Stop, and Target.
Main settings
Detection:
- Pivot strength
- Equality tolerance in ATR
- Minimum pattern height
- Minimum pattern quality
- Maximum pattern length
Display:
- Show only latest pattern
- Show pattern lines
- Show entry / stop / target levels
- Show R:R in entry label
- Fade inactive levels after result
- Entry / stop / target projection length
- Pattern line width
- Entry / stop / target line width
- Entry / stop / target label size
Colors:
- Pattern colors
- Entry line color
- Stop line color
- Target line color
- Entry text color
- Stop text color
- Target text color
- Resolved / inactive level styling
How to use
Use the indicator as a visual assistant for identifying and reviewing chart-pattern structures.
A detected pattern means the required swing geometry has formed. It does not mean that the pattern will complete successfully or that price will reach the target.
Users can choose to display only the latest pattern for a clean chart, or keep more visual history by changing the display settings.
Repainting note
This script uses confirmed pivot highs and confirmed pivot lows. A pattern can only be detected after the required pivot confirmation bars have passed.
For this reason, pattern drawings may appear on earlier swing points after confirmation. This is a normal confirmation delay caused by pivot-based detection.
The script does not use lookahead. Entry, stop, target, and state labels update only as new bars develop after a pattern has been detected.
Limitations
Chart patterns are geometric interpretations of price structure. Different traders may classify the same structure differently.
The displayed Entry, Stop, Target, and R:R values are reference levels calculated from the pattern geometry. They should not be treated as financial advice, trading instructions, or guaranteed outcomes.
The indicator is intended for chart analysis, education, and visual pattern review.
The script identifies selected classic chart-pattern structures and draws them directly on the chart. It is designed as a visual pattern-mapping tool, not as an automated trading system.
What the script detects
Reversal patterns:
- Double Top
- Double Bottom
- Triple Top
- Triple Bottom
- Head and Shoulders
- Inverted Head and Shoulders
Continuation / structure patterns:
- Rectangles
- Ascending Triangle
- Descending Triangle
- Symmetrical Triangle
- Rising Wedge
- Falling Wedge
- Bull Flag
- Bear Flag
- Bullish Pennant
- Bearish Pennant
How it works
The script uses confirmed pivot highs and pivot lows to build a swing structure. It then compares the most recent confirmed swings against geometric conditions such as:
- Similarity of highs or lows
- Pattern height relative to ATR
- Slope of upper and lower boundaries
- Convergence or parallel behavior
- Pattern duration
- Flag or pennant context when applicable
Each detected pattern receives a quality score. This score is based on the geometry of the pattern, such as symmetry, height, similarity of key swing points, slope behavior, and structure fit. The score is intended to help users filter weaker shapes from cleaner structures.
Entry, Stop, and Target levels
The script can display Entry, Stop, and Target reference levels for detected patterns.
These levels are geometric references derived from the detected pattern structure. They are not trade recommendations.
The script can also track the state of the detected setup:
- Pending: the pattern is detected but entry has not been triggered
- Active: entry level has been reached
- Target Hit: price reached the target reference level
- Stop Hit: price reached the stop reference level
- Expired: the setup remained unresolved beyond the selected time window
The Entry label can also show an estimated R:R value based on the distance between Entry, Stop, and Target.
Main settings
Detection:
- Pivot strength
- Equality tolerance in ATR
- Minimum pattern height
- Minimum pattern quality
- Maximum pattern length
Display:
- Show only latest pattern
- Show pattern lines
- Show entry / stop / target levels
- Show R:R in entry label
- Fade inactive levels after result
- Entry / stop / target projection length
- Pattern line width
- Entry / stop / target line width
- Entry / stop / target label size
Colors:
- Pattern colors
- Entry line color
- Stop line color
- Target line color
- Entry text color
- Stop text color
- Target text color
- Resolved / inactive level styling
How to use
Use the indicator as a visual assistant for identifying and reviewing chart-pattern structures.
A detected pattern means the required swing geometry has formed. It does not mean that the pattern will complete successfully or that price will reach the target.
Users can choose to display only the latest pattern for a clean chart, or keep more visual history by changing the display settings.
Repainting note
This script uses confirmed pivot highs and confirmed pivot lows. A pattern can only be detected after the required pivot confirmation bars have passed.
For this reason, pattern drawings may appear on earlier swing points after confirmation. This is a normal confirmation delay caused by pivot-based detection.
The script does not use lookahead. Entry, stop, target, and state labels update only as new bars develop after a pattern has been detected.
Limitations
Chart patterns are geometric interpretations of price structure. Different traders may classify the same structure differently.
The displayed Entry, Stop, Target, and R:R values are reference levels calculated from the pattern geometry. They should not be treated as financial advice, trading instructions, or guaranteed outcomes.
The indicator is intended for chart analysis, education, and visual pattern review.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.