Updated
Multi-Pattern Formation Detector

Multi-Pattern Formation Detector is an overlay indicator for Pine Script® v6 that automatically detects and draws classical chart formations using a touch-based approach. Instead of fitting lines to arbitrary points, the script identifies confirmed swing highs and lows, then searches for trend boundaries that price has repeatedly touched while respecting strict tolerance and violation rules.
This tool is designed to help traders visualize structure on the chart — trend direction, consolidation zones, and potential breakout levels — without manually drawing every line. You choose which formation families to enable; the indicator handles detection, labeling, optional history, alerts, and a side formation table.
What makes OnlyTrend Touch different?
Why invite-only access?
Many free tools draw a trend line between two pivots or label every triangle-like shape on the chart. OnlyTrend Touch goes further: it runs a unified touch-validation engine across seven formation families, scores competing candidates, and keeps only boundaries that survive multi-touch, violation, convergence, and containment tests.
If you only need a single manual trend line, a basic built-in tool may be enough. OnlyTrend Touch is built for traders who want automated, rule-based classical pattern detection with strict validation and multi-pattern coverage on one chart.
Supported formations
Trend Lines — Up trend (support through swing lows) and down trend (resistance through swing highs). Solid segment shows the fitted zone; dashed segment extends to the current bar.
Parallel Channels — Ascending, Descending, or Horizontal channels built from a base trend line plus a parallel opposite boundary. Named automatically from slope.
Classic Triangles — Ascending, Descending, and Symmetrical. Filter by type or search all. Optional apex marker.
Wedges — Rising Wedge (both boundaries slope up; lower is steeper) and Falling Wedge (both slope down; upper is steeper). Filter by type or search all.
Flags — Bull/Bear flag: impulse pole + parallel consolidation channel.
Pennants — Bull/Bear pennant: impulse pole + converging consolidation (triangle-like).
Support & Resistance — Unbroken pivot highs (resistance) and pivot lows (support) drawn as horizontal levels.
Visual examples
Down trend line and ascending channel on US100:

Descending channel and ascending channel on XU100:

Descending triangle on POLHO:

Support and resistance levels on XU100:

How to use
Recommended starting workflow
Settings reference
Formation
Multi-select checkboxes — only enabled types are calculated and drawn.
Swing Points
Touch Fitting
Shared tolerances used across trend, channel, triangle, wedge, flag, pennant, and S/R logic.
Trend Lines
Down trends connect swing highs with descending resistance. Up trends connect swing lows with ascending support. When other formations are enabled, trend breakout markers are suppressed to reduce chart clutter.
Channel
Channel types detected: Ascending Channel, Descending Channel, Horizontal Channel.
Triangle
Wedge
Flag & Pennant
Flag — Parallel consolidation channel after a sharp pole (continuation pattern).
Pennant — Small converging triangle after a sharp pole (continuation pattern).
Support / Resistance
Levels are drawn from recent pivot highs/lows that have not been meaningfully broken (close beyond level ± violation tolerance).
Breakouts
Show Breakout Markers — Visual markers when price closes through an active boundary. Trend-line break markers are hidden when channel, triangle, wedge, flag, or pennant modules are active to keep the chart readable.
Alerts
Two alert layers are available:
Enable the corresponding checkbox in the Alerts input group, then create a PulseWire alert on this indicator and select the matching alertcondition title from the dropdown.
Available alert toggles:
Display
Performance notes
Interpretation guide
Limitations
Version
Pine Script® v6 | Overlay indicator | Invite-only access
Max bars back: 5000
This tool is designed to help traders visualize structure on the chart — trend direction, consolidation zones, and potential breakout levels — without manually drawing every line. You choose which formation families to enable; the indicator handles detection, labeling, optional history, alerts, and a side formation table.
Disclaimer
This indicator is provided for educational and analytical purposes only. It does not constitute investment advice, a trading recommendation, or a guarantee of future results. All trading involves risk. Past pattern behavior does not predict future price movement. Always perform your own analysis and risk management before making any financial decision.
What makes OnlyTrend Touch different?
- Touch-validated boundaries — Lines must be supported by multiple swing touches within an ATR-based tolerance, not just two visually picked pivots.
- Violation filtering — Price closes that pierce a boundary beyond tolerance can invalidate a candidate line, with a configurable grace zone near the current bar.
- Multi-formation engine — Enable only what you need: Trend Lines, Channel, Triangle, Wedge, Flag, Pennant, and/or Support & Resistance.
- Strict classic pattern rules — Triangles and wedges use convergence, touch spread, containment, and optional two-half touch requirements to reduce random shapes.
- Active + historical view — See the current best formation plus optional past patterns within a lookback window.
- Formation table — A sortable side table lists detected formations with start date, end date, and Active/Past status.
- Granular alerts — Separate toggles for formation activation and boundary break events.
Why invite-only access?
Many free tools draw a trend line between two pivots or label every triangle-like shape on the chart. OnlyTrend Touch goes further: it runs a unified touch-validation engine across seven formation families, scores competing candidates, and keeps only boundaries that survive multi-touch, violation, convergence, and containment tests.
- One indicator, full structure toolkit — Trend lines, parallel channels, classic triangles, wedges, flags, pennants, and pivot S/R in a single overlay, sharing the same swing and tolerance logic.
- Quality over quantity — Triangles and wedges require minimum touch spread, price containment (default 95%), optional touches in both halves of the pattern, and zero tolerance for pattern violations by default. This filters out most random wedge/triangle shapes.
- Scored best-fit selection — When several valid candidates exist, the script picks the highest-scoring formation per type instead of drawing the first geometric match.
- Active + historical workflow — Review the current pattern, scan past formations inside a lookback window, and track them in a dated side table — without switching indicators.
- Production-ready alerts — Separate activation and breakout alerts for every formation type, configurable from inputs.
- Protected, maintained release — Source code is invite-only to protect the custom detection logic. Access supports a maintained tool with documented settings and ongoing updates, not an unsupported copy.
If you only need a single manual trend line, a basic built-in tool may be enough. OnlyTrend Touch is built for traders who want automated, rule-based classical pattern detection with strict validation and multi-pattern coverage on one chart.
Supported formations
Trend Lines — Up trend (support through swing lows) and down trend (resistance through swing highs). Solid segment shows the fitted zone; dashed segment extends to the current bar.
Parallel Channels — Ascending, Descending, or Horizontal channels built from a base trend line plus a parallel opposite boundary. Named automatically from slope.
Classic Triangles — Ascending, Descending, and Symmetrical. Filter by type or search all. Optional apex marker.
Wedges — Rising Wedge (both boundaries slope up; lower is steeper) and Falling Wedge (both slope down; upper is steeper). Filter by type or search all.
Flags — Bull/Bear flag: impulse pole + parallel consolidation channel.
Pennants — Bull/Bear pennant: impulse pole + converging consolidation (triangle-like).
Support & Resistance — Unbroken pivot highs (resistance) and pivot lows (support) drawn as horizontal levels.
Visual examples
Down trend line and ascending channel on US100:
Descending channel and ascending channel on XU100:
Descending triangle on POLHO:
Support and resistance levels on XU100:
How to use
- Add the indicator to your chart. It runs as an overlay on price.
- In Formation, enable the pattern types you want to scan. Leave unused types off for faster loading.
- Adjust Swing Points and Touch Fitting to match your symbol and timeframe.
- Open the style group for each enabled formation (Trend, Channel, Triangle, etc.) to customize colors, fills, labels, and strictness.
- Use Display to toggle historical drawings and the formation table.
- Enable desired Alerts checkboxes, then create a PulseWire alert on the indicator and pick the matching condition.
Recommended starting workflow
- Begin with Trend Lines only. Set Pivot Sensitivity to 10 and review touch markers.
- Add Channel or Triangle one at a time. Heavy multi-pattern scans are more CPU-intensive.
- If patterns feel too loose, increase Min Touches, Min Price Containment %, or reduce Max Violations.
- If patterns are missing, slightly increase Touch Tolerance (ATR x) or decrease Pivot Sensitivity.
- Disable Show History on lower timeframes or long lookbacks if chart refresh feels slow.
Settings reference
Formation
Multi-select checkboxes — only enabled types are calculated and drawn.
- Trend Lines — Up/down trend line detection.
- Channel — Parallel price channel detection.
- Triangle — Classic triangle patterns.
- Wedge — Rising and falling wedge patterns.
- Flag — Bull and bear flag patterns.
- Pennant — Bull and bear pennant patterns.
- S/R — Unbroken pivot support and resistance levels.
Swing Points
- Pivot Sensitivity (2–30, default 10) — Bars left and right required to confirm a swing high or low. Higher = fewer, more significant swings. Lower = more swings, more candidates.
- Max Swings (4–20, default 12) — How many recent swing points are kept for line fitting.
Touch Fitting
Shared tolerances used across trend, channel, triangle, wedge, flag, pennant, and S/R logic.
- ATR Period (default 14) — ATR length for tolerance scaling.
- Touch Tolerance (ATR x) (0.05–2.0, default 0.1) — Maximum distance between a swing and a boundary to count as a touch.
- Violation Tolerance (ATR x) (0–2.0, default 0.15) — How far price may pierce a boundary before counting as a violation.
- Min Touches (2–15, default 2) — Minimum swing touches required to validate a single trend boundary.
- Min Bar Span (2–100, default 8) — Minimum horizontal distance between the two anchor pivots of a line.
- Max Violations (0–20, default 1) — Maximum tolerated boundary violations along a line's life.
- Break Distance (0–20, default 5) — Violations within the last N bars do not invalidate a line (keeps active boundaries stable near price).
Trend Lines
- Down Trend / Up Trend — Toggle each direction independently.
- Show Touches — Mark confirmed touch points on the line.
- Show Labels — Display live price, touch count, and distance % at the extended line.
- Down Color / Up Color — Line and marker colors.
- Down Width / Up Width — Line thickness (1–5).
Down trends connect swing highs with descending resistance. Up trends connect swing lows with ascending support. When other formations are enabled, trend breakout markers are suppressed to reduce chart clutter.
Channel
- Flat Slope (ATR/bar) (default 0.02) — Slopes below this threshold classify the channel as horizontal.
- Show Fill / Show Touches / Show Label — Visual options for the active channel.
- Upper Color / Lower Color / Fill Color — Channel styling.
- Line Width (1–5).
- Base Trend Candidates (2–10, default 6) — Number of base trend lines tested before building the parallel boundary. Higher = more thorough search, slower performance.
Channel types detected: Ascending Channel, Descending Channel, Horizontal Channel.
Triangle
- Min Convergence % (1–50, default 5) — Required width reduction from pattern start to end.
- Min Touch Spread % (10–80, default 25) — Each boundary's touches must span at least this percentage of the pattern width.
- Touches in Both Halves (default on) — Each boundary must register touches in both the left and right half of the pattern.
- Triangle Type — All, Ascending, Descending, or Symmetrical.
- Show Fill / Show Touches / Show Label / Show Apex — Visual options.
- Upper Color / Lower Color / Fill Color / Line Width — Styling.
- Boundary Candidates (2–10, default 6) — Top candidate lines per side in the pair search.
- Flat Slope (ATR/bar) (default 0.008) — Stricter horizontal threshold for ascending/descending triangle flat sides.
- Min Touches / Boundary (2–10, default 3) — Minimum touches on each triangle boundary.
- Min Price Containment % (70–100, default 95) — Minimum share of pattern bars where price stays inside both boundaries.
- Max Pattern Violations (0–20, default 0) — Maximum bars that may trade outside the triangle during the pattern.
- Ascending Triangle — Flat upper boundary + rising lower boundary.
- Descending Triangle — Flat lower boundary + falling upper boundary.
- Symmetrical Triangle — Both boundaries converge with opposing slopes.
Wedge
- Min Convergence % (default 5) — Required narrowing between boundaries.
- Min Touch Spread % (default 25) — Touch distribution requirement per boundary.
- Touches in Both Halves (default on).
- Wedge Type — All, Rising, or Falling.
- Min Slope (ATR/bar) (default 0.006) — Both boundaries must slope meaningfully in the wedge direction.
- Min Touches / Boundary (default 3).
- Min Price Containment % (default 95).
- Max Pattern Violations (default 0).
- Show Fill / Show Touches / Show Label / Show Apex — Visual options.
- Upper Color / Lower Color / Fill Color / Line Width — Styling.
- Boundary Candidates (2–10, default 6).
- Rising Wedge — Both boundaries slope upward; the lower line is steeper (converging upward).
- Falling Wedge — Both boundaries slope downward; the upper line is steeper (converging downward).
Flag & Pennant
- Min Pole Bars / Max Pole Bars (default 6 / 20) — Impulse leg length limits.
- Min Consol. Bars / Max Consol. Bars (default 5 / 18) — Consolidation length after the pole.
- Min Touch Span (default 3) — Minimum bar span for consolidation trend lines.
- Pole Size (ATR x) (default 2.5) — Minimum impulse move relative to ATR.
- Max Consol / Pole % (default 60) — Consolidation height must be smaller than this percentage of pole height.
- Pennant Min Conv. % (default 3) — Minimum convergence for pennant consolidation.
- Show Fill / Show Label / Show Touches — Visual options.
- Pole Color / Upper Color / Lower Color / Fill Color / Line Width — Styling.
- Consol. Candidates (2–8, default 4) — Consolidation boundary candidates.
Flag — Parallel consolidation channel after a sharp pole (continuation pattern).
Pennant — Small converging triangle after a sharp pole (continuation pattern).
Support / Resistance
- Resistance / Support — Toggle each side.
- Show Labels — Price labels on levels.
- Max Levels (1–20, default 10) — Maximum unbroken pivot levels drawn per side.
- Resistance Color / Support Color — Level styling.
Levels are drawn from recent pivot highs/lows that have not been meaningfully broken (close beyond level ± violation tolerance).
Breakouts
Show Breakout Markers — Visual markers when price closes through an active boundary. Trend-line break markers are hidden when channel, triangle, wedge, flag, or pennant modules are active to keep the chart readable.
Alerts
Two alert layers are available:
- State alerts — Fire when a formation becomes active (e.g. "Up Trend Active", "Triangle Active").
- Breakout alerts — Fire on boundary breaks (e.g. "Channel Upper Break", "Triangle Lower Break", "Resistance Break").
Enable the corresponding checkbox in the Alerts input group, then create a PulseWire alert on this indicator and select the matching alertcondition title from the dropdown.
Available alert toggles:
- Up Trend Active / Down Trend Active
- Channel Active / Triangle Active / Wedge Active
- Flag Active / Pennant Active / S/R Active
- Up Trend Break ↓ / Down Trend Break ↑
- Channel Upper Break ↑ / Channel Lower Break ↓
- Triangle Upper Break ↑ / Triangle Lower Break ↓
- Wedge Upper Break ↑ / Wedge Lower Break ↓
- Flag Break (trend dir) / Pennant Break (trend dir)
- Resistance Break ↑ / Support Break ↓
Display
- Show History (default on) — Draw past formations found within the lookback window (faded style). Historical scan runs on the last bar.
- History Lookback (50–5000, default 400) — Bars scanned backward for completed patterns.
- Max History (1–15, default 5) — Maximum number of historical formations drawn per type.
- History Scan Step (5–50, default 20) — Step size when scanning for past pattern end points. Larger = faster scan, coarser history.
- Formation Table (default on) — Side table with columns: #, Formation, Start, End, Status (Active/Past).
- Table Position — top_right, top_left, bottom_right, bottom_left, middle_right.
- Max Table Rows (3–50, default 25).
- Text Color / Table Background / Table Header — Table styling.
Performance notes
- Pattern search (channel, triangle, wedge, flag, pennant) runs on the last bar only and is cached — this keeps replay smooth but may take a moment when the chart first loads.
- Enable only the formation types you actively use.
- Reduce History Lookback, Max History, or increase History Scan Step if refresh feels slow.
- Lower Boundary Candidates / Base Trend Candidates for faster scans on dense charts.
- Wedge and triangle modules are the most computationally heavy.
Interpretation guide
- Solid vs dashed lines — Solid segment = fitted historical zone. Dashed segment = extension to the current bar.
- Touch markers (●) — Confirmed swing points that validated the boundary.
- Active formation — The highest-scoring valid pattern of each enabled type at the current bar.
- Past formation — A previously completed pattern inside the lookback window; shown with reduced opacity when history is enabled.
- Breakout marker — Price closed beyond the boundary on that bar (not a trade signal by itself).
Limitations
- The indicator selects the best-scoring candidate per type — it does not draw every possible geometric shape on the chart.
- Very noisy or low-liquidity symbols may produce fewer valid patterns under strict settings.
- Flag and pennant detection depends on a clear prior impulse pole; choppy markets may skip these patterns.
- S/R levels are pivot-based and unbroken — they disappear once price closes through them beyond tolerance.
- Multi-pattern mode increases visual complexity; use formation checkboxes to focus analysis.
Version
Pine Script® v6 | Overlay indicator | Invite-only access
Max bars back: 5000
Release Notes
Short name and name changed.Available in Paid Space
This indicator is only available to TrendLAB subscribers. Join to access this and other scripts by only_fibonacci.
Love for AlgoTrading
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by PulseWire. Read more in the Terms of Use.
Available in Paid Space
This indicator is only available to TrendLAB subscribers. Join to access this and other scripts by only_fibonacci.
Love for AlgoTrading
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by PulseWire. Read more in the Terms of Use.
