OPEN-SOURCE SCRIPT
KIRON Universal Pattern Engine

KIRON Universal Pattern Engine
The KIRON Universal Pattern Engine is a multi-pattern technical-analysis indicator designed to identify developing and completed chart formations, draw their full structure directly on the chart, and construct an objective trade plan for the strongest eligible setup.
The indicator is designed for use across liquid markets—including forex, gold, indices, commodities, equities and cryptocurrencies—and can be applied to different chart timeframes. Volatility-sensitive calculations are normalised using Average True Range (ATR), allowing the detection thresholds and trade levels to adapt to the instrument being analysed.
PATTERNS DETECTED
The engine searches for:
• Double Bottom
• Double Top
• Triple Bottom
• Triple Top
• Head and Shoulders
• Inverse Head and Shoulders
• Rectangle
• Ascending Triangle
• Descending Triangle
• Symmetrical Triangle
• Bull Flag
• Bear Flag
• Bull Pennant
• Bear Pennant
• Rising Wedge
• Falling Wedge
• Cup and Handle
FULL PATTERN VISUALISATION
Each formation is drawn using its actual structural points rather than represented by a generic box.
Depending on the formation, the indicator can display:
• Pattern highs and lows
• Peaks, troughs and shoulders
• Head and shoulder points
• Necklines
• Support and resistance boundaries
• Upper and lower trendlines
• Flagpoles and consolidation channels
• Pennant and triangle boundaries
• Wedge convergence
• Pattern apex
• Cup and handle geometry
• Breakout or invalidation information
Bullish structures use bullish colours, while bearish structures use bearish colours. Neutral structural levels—such as necklines and horizontal boundaries—are displayed separately for clarity.
DEVELOPING PATTERNS
The indicator is designed to identify formations while they are developing, rather than waiting until the entire subsequent price move has already occurred.
A developing formation can change as new confirmed swing points become available. Once its structural pivots have been confirmed, those historical pivot points are not moved retrospectively.
This distinction is important:
• Confirmed pivot points do not repaint.
• An unfinished formation may evolve, be replaced or become invalid as new price information arrives.
• A breakout is not guaranteed simply because a developing structure has been identified.
CANDIDATE SELECTION
Several formations may be detected within the same market structure. The engine therefore evaluates each eligible candidate using:
• Structural validity
• Pattern quality
• Direction
• Pattern priority
• Formation age
• Volatility-adjusted tolerances
• Availability of the required confirmed pivot sequence
Where several patterns compete for the same area of price action, the engine ranks them and selects the strongest current candidate for the trade plan.
The number of visible historical patterns is limited to prevent excessive chart clutter.
PATTERN QUALITY
Every valid formation receives a quality measurement based on how closely its confirmed swing structure matches the expected geometry of that pattern.
A higher score represents a closer geometric match. It does not represent a guaranteed probability of success.
The minimum quality setting can be increased to produce fewer but more selective formations, or reduced to allow more developing candidates to appear.
ENTRY, STOP LOSS AND PROFIT TARGETS
The strongest eligible directional pattern receives a complete volatility-adjusted trade plan.
The plan includes:
• Entry
• Stop Loss
• Take Profit 1
• Take Profit 2
• Take Profit 3
• Initial price risk
• Direction of the setup
The entry is calculated from the relevant breakout boundary with an optional ATR-based entry buffer.
The stop loss is placed beyond the pattern’s structural failure point, with an additional ATR-based protective buffer.
Profit targets are calculated as configurable multiples of the initial risk:
• TP1 = Entry plus or minus the selected first risk multiple
• TP2 = Entry plus or minus the selected second risk multiple
• TP3 = Entry plus or minus the selected third risk multiple
For bullish setups, targets are projected above the entry. For bearish setups, targets are projected below the entry.
Trade levels are only produced when the engine can construct a logically valid directional plan with positive risk.
DASHBOARD
The dashboard provides a concise summary of the strongest current setup, including:
• Current verdict
• Selected pattern
• Bullish, bearish or unresolved direction
• Pattern quality
• Number of live candidates
• Entry price
• Stop-loss price
• TP1
• TP2
• TP3
• Initial risk
• Number of stored patterns
If no eligible formation is available, the dashboard reports that there is no valid setup rather than manufacturing trade levels.
MAIN SETTINGS
Confirmed Pivot Length
Controls how many bars are required on each side of a swing before that pivot is confirmed. A smaller value increases sensitivity, while a larger value identifies broader market structures.
ATR Length
Controls the volatility measurement used by the pattern tolerances, entry buffer and stop-loss calculation.
Level Tolerance
Determines how closely two or more swing prices must align to be treated as equivalent support, resistance, tops or bottoms.
Minimum Pattern Height
Prevents extremely small price fluctuations from being classified as meaningful formations.
Minimum Pattern Quality
Controls the minimum structural quality required before a candidate is accepted.
Maximum Pattern Age
Determines how long a detected formation remains eligible for current analysis.
Maximum Visible Patterns
Limits the number of formations displayed simultaneously to preserve chart readability.
Entry Buffer
Adds volatility-adjusted confirmation beyond the breakout boundary.
Stop Buffer
Adds volatility-adjusted protection beyond the structural invalidation point.
Target Risk Multiples
Controls the risk-to-reward calculations used for TP1, TP2 and TP3.
SUGGESTED WORKFLOW
1. Begin with a higher timeframe to establish the broader market structure and directional context.
2. Use the indicator to identify a developing or completed formation.
3. Examine the full visual geometry rather than relying only on the pattern name.
4. Review the quality score and direction shown on the dashboard.
5. Wait for appropriate breakout confirmation where required.
6. Confirm that the proposed entry, stop and targets are suitable for current liquidity, spread and market conditions.
7. Avoid entering immediately before major economic announcements or during abnormal volatility.
8. Apply independent position sizing and account-level risk management.
IMPORTANT LIMITATIONS
Chart-pattern recognition is inherently interpretative. Two traders may identify different formations within the same price structure.
Confirmed pivots require future bars before they become established. This introduces confirmation delay but prevents historical swing points from being treated as confirmed prematurely.
A detected pattern can fail, remain range-bound or break in the opposite direction. Pattern quality measures geometric conformity—not future performance or certainty.
ATR-based calculations adapt to volatility but cannot account for every market condition, including gaps, slippage, illiquidity, news shocks or sudden spread expansion.
The indicator should be used as a structured decision-support tool and not as a standalone instruction to enter a trade.
RISK DISCLAIMER
This indicator is provided for educational and analytical purposes only. It does not constitute financial or investment advice.
Trading leveraged products, forex, commodities, indices and cryptocurrencies involves substantial risk. Historical formations and projected targets do not guarantee future results. Users remain responsible for independently evaluating every setup, selecting appropriate position size and managing their own risk.
The KIRON Universal Pattern Engine is a multi-pattern technical-analysis indicator designed to identify developing and completed chart formations, draw their full structure directly on the chart, and construct an objective trade plan for the strongest eligible setup.
The indicator is designed for use across liquid markets—including forex, gold, indices, commodities, equities and cryptocurrencies—and can be applied to different chart timeframes. Volatility-sensitive calculations are normalised using Average True Range (ATR), allowing the detection thresholds and trade levels to adapt to the instrument being analysed.
PATTERNS DETECTED
The engine searches for:
• Double Bottom
• Double Top
• Triple Bottom
• Triple Top
• Head and Shoulders
• Inverse Head and Shoulders
• Rectangle
• Ascending Triangle
• Descending Triangle
• Symmetrical Triangle
• Bull Flag
• Bear Flag
• Bull Pennant
• Bear Pennant
• Rising Wedge
• Falling Wedge
• Cup and Handle
FULL PATTERN VISUALISATION
Each formation is drawn using its actual structural points rather than represented by a generic box.
Depending on the formation, the indicator can display:
• Pattern highs and lows
• Peaks, troughs and shoulders
• Head and shoulder points
• Necklines
• Support and resistance boundaries
• Upper and lower trendlines
• Flagpoles and consolidation channels
• Pennant and triangle boundaries
• Wedge convergence
• Pattern apex
• Cup and handle geometry
• Breakout or invalidation information
Bullish structures use bullish colours, while bearish structures use bearish colours. Neutral structural levels—such as necklines and horizontal boundaries—are displayed separately for clarity.
DEVELOPING PATTERNS
The indicator is designed to identify formations while they are developing, rather than waiting until the entire subsequent price move has already occurred.
A developing formation can change as new confirmed swing points become available. Once its structural pivots have been confirmed, those historical pivot points are not moved retrospectively.
This distinction is important:
• Confirmed pivot points do not repaint.
• An unfinished formation may evolve, be replaced or become invalid as new price information arrives.
• A breakout is not guaranteed simply because a developing structure has been identified.
CANDIDATE SELECTION
Several formations may be detected within the same market structure. The engine therefore evaluates each eligible candidate using:
• Structural validity
• Pattern quality
• Direction
• Pattern priority
• Formation age
• Volatility-adjusted tolerances
• Availability of the required confirmed pivot sequence
Where several patterns compete for the same area of price action, the engine ranks them and selects the strongest current candidate for the trade plan.
The number of visible historical patterns is limited to prevent excessive chart clutter.
PATTERN QUALITY
Every valid formation receives a quality measurement based on how closely its confirmed swing structure matches the expected geometry of that pattern.
A higher score represents a closer geometric match. It does not represent a guaranteed probability of success.
The minimum quality setting can be increased to produce fewer but more selective formations, or reduced to allow more developing candidates to appear.
ENTRY, STOP LOSS AND PROFIT TARGETS
The strongest eligible directional pattern receives a complete volatility-adjusted trade plan.
The plan includes:
• Entry
• Stop Loss
• Take Profit 1
• Take Profit 2
• Take Profit 3
• Initial price risk
• Direction of the setup
The entry is calculated from the relevant breakout boundary with an optional ATR-based entry buffer.
The stop loss is placed beyond the pattern’s structural failure point, with an additional ATR-based protective buffer.
Profit targets are calculated as configurable multiples of the initial risk:
• TP1 = Entry plus or minus the selected first risk multiple
• TP2 = Entry plus or minus the selected second risk multiple
• TP3 = Entry plus or minus the selected third risk multiple
For bullish setups, targets are projected above the entry. For bearish setups, targets are projected below the entry.
Trade levels are only produced when the engine can construct a logically valid directional plan with positive risk.
DASHBOARD
The dashboard provides a concise summary of the strongest current setup, including:
• Current verdict
• Selected pattern
• Bullish, bearish or unresolved direction
• Pattern quality
• Number of live candidates
• Entry price
• Stop-loss price
• TP1
• TP2
• TP3
• Initial risk
• Number of stored patterns
If no eligible formation is available, the dashboard reports that there is no valid setup rather than manufacturing trade levels.
MAIN SETTINGS
Confirmed Pivot Length
Controls how many bars are required on each side of a swing before that pivot is confirmed. A smaller value increases sensitivity, while a larger value identifies broader market structures.
ATR Length
Controls the volatility measurement used by the pattern tolerances, entry buffer and stop-loss calculation.
Level Tolerance
Determines how closely two or more swing prices must align to be treated as equivalent support, resistance, tops or bottoms.
Minimum Pattern Height
Prevents extremely small price fluctuations from being classified as meaningful formations.
Minimum Pattern Quality
Controls the minimum structural quality required before a candidate is accepted.
Maximum Pattern Age
Determines how long a detected formation remains eligible for current analysis.
Maximum Visible Patterns
Limits the number of formations displayed simultaneously to preserve chart readability.
Entry Buffer
Adds volatility-adjusted confirmation beyond the breakout boundary.
Stop Buffer
Adds volatility-adjusted protection beyond the structural invalidation point.
Target Risk Multiples
Controls the risk-to-reward calculations used for TP1, TP2 and TP3.
SUGGESTED WORKFLOW
1. Begin with a higher timeframe to establish the broader market structure and directional context.
2. Use the indicator to identify a developing or completed formation.
3. Examine the full visual geometry rather than relying only on the pattern name.
4. Review the quality score and direction shown on the dashboard.
5. Wait for appropriate breakout confirmation where required.
6. Confirm that the proposed entry, stop and targets are suitable for current liquidity, spread and market conditions.
7. Avoid entering immediately before major economic announcements or during abnormal volatility.
8. Apply independent position sizing and account-level risk management.
IMPORTANT LIMITATIONS
Chart-pattern recognition is inherently interpretative. Two traders may identify different formations within the same price structure.
Confirmed pivots require future bars before they become established. This introduces confirmation delay but prevents historical swing points from being treated as confirmed prematurely.
A detected pattern can fail, remain range-bound or break in the opposite direction. Pattern quality measures geometric conformity—not future performance or certainty.
ATR-based calculations adapt to volatility but cannot account for every market condition, including gaps, slippage, illiquidity, news shocks or sudden spread expansion.
The indicator should be used as a structured decision-support tool and not as a standalone instruction to enter a trade.
RISK DISCLAIMER
This indicator is provided for educational and analytical purposes only. It does not constitute financial or investment advice.
Trading leveraged products, forex, commodities, indices and cryptocurrencies involves substantial risk. Historical formations and projected targets do not guarantee future results. Users remain responsible for independently evaluating every setup, selecting appropriate position size and managing their own risk.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.