OPEN-SOURCE SCRIPT
Pattern Scanner AI AlgoCode

Automatic chart pattern detection with a complete, ready-to-trade level map.
Pattern Scanner AI AlgoCode is a pivot-based structure engine that finds classic reversal and continuation patterns in real time and turns each of them into a clean trade plan: entry, retest, stop-loss and two targets with a live R:R readout.
What it detects
Entry Engine
A pattern alone is not a signal. The Entry Engine confirms the actual breakout of the neckline / wedge boundary:
ATR breakout buffer — price must clear the level by a volatility-scaled margin, filtering micro-fakeouts.
Body close confirmation — optional requirement that the candle body, not just the wick, closes beyond the level.
Volume filter — optional requirement of volume above its 20-period average by a chosen multiplier.
Retest level — an additional, better-priced entry line for traders who wait for the pullback into the broken level.
Cooldown — a minimum bar distance between signals to avoid clusters of duplicates.
Trade levels on every setup
E (Entry) — breakout level projected forward as a solid ray.
Retest — dotted alternative entry.
SL — stop beyond the pattern extreme with an ATR safety buffer.
TP1 — classic measured move (pattern height).
TP2 — extended target (default 1.618 × pattern height).
R:R — real risk/reward, calculated with the buffered stop, printed on the setup label.
Risk and reward zones are shaded so the trade structure is readable at a glance.
Visualization
Pattern skeleton drawn through the actual pivot points, with marked vertices.
Compact price labels for every level, placed to the right of the signal bar.
Full setup history: the last N setups stay on the chart (configurable up to 40), older drawings are pruned automatically to keep performance high.
Optional pivot markers for a quick health check of your settings.
Bullish / bearish signal triangles on the breakout bar.
Alerts
Built-in alert() calls and separate bullish / bearish alertcondition streams, including the pattern name, ticker and timeframe — ready for TradingView notifications, webhooks and bots.
Settings overview
Pivots & accuracy — pivot left/right, tolerance mode (ATR / percent), min height, min/max width, min R:R, cooldown.
Entry engine — breakout buffer, body-close requirement, volume filter, retest offset, stop buffer, TP2 multiplier.
Patterns — enable or disable each family independently.
Display — levels, pattern outline, pivot points, risk/reward zones, projection length, history depth, alerts.
How to use
Add the indicator to any symbol and timeframe.
Increase Pivot left / right on lower timeframes for cleaner structure, decrease for more signals.
Keep the body close confirmation on for stricter entries; add the volume filter on liquid instruments.
Trade the E level on the breakout candle, or wait for the Retest line for a better price.
Manage the position with SL, take partials at TP1, run the rest to TP2.
Notes
Works on all markets and timeframes (crypto, forex, indices, stocks). Non-repainting on confirmed breakouts: signals fire on bar close conditions, while pivots require their right-side confirmation window by design.
This script is a technical analysis tool, not financial advice. Always test settings on your instrument and manage risk.
AI AlgoCode
Pattern Scanner AI AlgoCode is a pivot-based structure engine that finds classic reversal and continuation patterns in real time and turns each of them into a clean trade plan: entry, retest, stop-loss and two targets with a live R:R readout.
What it detects
- Double Top / Double Bottom
- Triple Top / Triple Bottom
- Head & Shoulders / Inverse Head & Shoulders
- Rising Wedge / Falling Wedge
- Every pattern is validated by geometry, not by guesswork: swing highs and lows are confirmed with configurable pivot windows, peak equality is measured with an ATR- or percent-based tolerance, and each candidate must pass minimum height, minimum/maximum width and minimum R:R filters before it is plotted.
Entry Engine
A pattern alone is not a signal. The Entry Engine confirms the actual breakout of the neckline / wedge boundary:
ATR breakout buffer — price must clear the level by a volatility-scaled margin, filtering micro-fakeouts.
Body close confirmation — optional requirement that the candle body, not just the wick, closes beyond the level.
Volume filter — optional requirement of volume above its 20-period average by a chosen multiplier.
Retest level — an additional, better-priced entry line for traders who wait for the pullback into the broken level.
Cooldown — a minimum bar distance between signals to avoid clusters of duplicates.
Trade levels on every setup
E (Entry) — breakout level projected forward as a solid ray.
Retest — dotted alternative entry.
SL — stop beyond the pattern extreme with an ATR safety buffer.
TP1 — classic measured move (pattern height).
TP2 — extended target (default 1.618 × pattern height).
R:R — real risk/reward, calculated with the buffered stop, printed on the setup label.
Risk and reward zones are shaded so the trade structure is readable at a glance.
Visualization
Pattern skeleton drawn through the actual pivot points, with marked vertices.
Compact price labels for every level, placed to the right of the signal bar.
Full setup history: the last N setups stay on the chart (configurable up to 40), older drawings are pruned automatically to keep performance high.
Optional pivot markers for a quick health check of your settings.
Bullish / bearish signal triangles on the breakout bar.
Alerts
Built-in alert() calls and separate bullish / bearish alertcondition streams, including the pattern name, ticker and timeframe — ready for TradingView notifications, webhooks and bots.
Settings overview
Pivots & accuracy — pivot left/right, tolerance mode (ATR / percent), min height, min/max width, min R:R, cooldown.
Entry engine — breakout buffer, body-close requirement, volume filter, retest offset, stop buffer, TP2 multiplier.
Patterns — enable or disable each family independently.
Display — levels, pattern outline, pivot points, risk/reward zones, projection length, history depth, alerts.
How to use
Add the indicator to any symbol and timeframe.
Increase Pivot left / right on lower timeframes for cleaner structure, decrease for more signals.
Keep the body close confirmation on for stricter entries; add the volume filter on liquid instruments.
Trade the E level on the breakout candle, or wait for the Retest line for a better price.
Manage the position with SL, take partials at TP1, run the rest to TP2.
Notes
Works on all markets and timeframes (crypto, forex, indices, stocks). Non-repainting on confirmed breakouts: signals fire on bar close conditions, while pivots require their right-side confirmation window by design.
This script is a technical analysis tool, not financial advice. Always test settings on your instrument and manage risk.
AI AlgoCode
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.