PROTECTED SOURCE SCRIPT

Double/Triple Tops & Bottoms & Rectangle Boxes

69
This indicator is an algorithmic pattern recognition tool designed to automatically identify, validate, and track significant reversal structures—specifically Double/Triple Tops and Bottoms. Unlike subjective drawing tools, this script uses a strict set of quantitative rules based on swing pivots and volatility (ATR) to define market structure.

The Logical Methodology The script operates on a three-stage "scientific" detection process:

Pivot Chaining (Level Detection): The algorithm scans for significant swing highs and lows using a user-defined lookback period. It stores these pivot levels and monitors subsequent price action. If price returns to a previous pivot level within a specific volatility threshold (normalized by ATR), it registers a "touch."

Pattern Construction (Neckline Identification): Once a level has been touched the required number of times (e.g., 2 for Double patterns, 3 for Triple patterns), the script calculates the "Neckline."

For Tops: It identifies the lowest trough between the peaks.

For Bottoms: It identifies the highest peak between the valleys. This creates a valid trading range, visualized as a blue box connecting the pivot level to the neckline.

Signal Validation (Breakout vs. Failure): The pattern remains in a "pending" state until a breakout occurs.

Confirmation: A signal is generated only when a candle closes beyond the neckline (below for Tops, above for Bottoms).

Invalidation: If price breaks the pivot level itself (e.g., makes a higher high on a Double Top) before breaking the neckline, the pattern is immediately marked invalid to prevent false signals.

Key Features

ATR-Based Sensitivity: Uses Average True Range to dynamically adjust how "precise" a re-test must be, adapting to changing market volatility.

Dual-Scanning: Can independently scan for Triple Tops (Bearish) and Double Bottoms (Bullish) simultaneously with separate settings.

Time & Width Constraints: Filters out "noise" by enforcing a minimum pattern width (in bars), ensuring only structurally significant patterns are displayed.

Settings Guide

Min Top/Bottom Touches: Set to 2 for Double patterns or 3 for Triple patterns.

Pivot Lookback: The number of bars used to define a swing point (higher = larger, more significant patterns).

Touch Sensitivity: Adjusts how strictly the price must match the previous level.

Min Pattern Width: Prevents the detection of micro-patterns that are too narrow to be reliable.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน