OPEN-SOURCE SCRIPT

VCP Trendline breakout

43
The Signal:
Green Triangles indicate the price is approaching the trendline (Watchlist candidate).
Yellow Triangles indicate the price is very tight against the line (Execution imminent).
The Trigger: When price closes above the Grey Dotted Line, the line stops extending. This is your breakout signal.

Indicator Overview
The The VCP Trendline breakout indicator is a sophisticated technical indicator designed for trend followers and breakout traders (O'Neil, Minervini, Wyckoff styles). This script employs a State Machine logic to identify structural Volatility Contraction Patterns (VCP) in real-time.
It automatically detects valid Bases, tracks the "Right Side" construction, identifies nested handles (contractions), and draws precise supply trendlines—while strictly enforcing structural integrity rules (Higher Lows).

Core Logic & Features

1. Smart Base Detection
Trend Filter: The pattern recognition engine only activates when the price is above the 200 SMA, ensuring you are trading with the primary trend.
Base Validation: It identifies a "Base High" (H1) based on a configurable lookback period. It tracks the depth of the base and automatically invalidates the pattern if the drawdown exceeds the user-defined threshold (default 30%).

2. Recursive Nested Trendlines (VCP)
The indicator is capable of drawing Nested Trendlines (recursive resistance). It doesn't just draw a line from the peak; it identifies internal contractions within the base.
H1 (Primary): The main supply line from the top of the base.
H2, H3 (Internal): Trendlines connecting subsequent lower highs (handles) as volatility contracts.
Smart Fan: Includes a "Clean Fan" mode to show only the most relevant, latest trendline per anchor point.

3. Structural Integrity Enforcement (The "Higher Low" Rule)
This is the standout feature of this script. It performs an Anchor Integrity Check on every bar.
In a valid VCP, every contraction must form a Higher Low.
If the price creates a new pivot (H3) but then crashes lower than the previous contraction's floor (H2), the script identifies this as a Structural Failure.
Auto-Deletion: It immediately retroactively deletes the invalid trendlines associated with that failed contraction, keeping your chart clean and free of "ghost" signals.

4. "Right-Side" Logic
Collision Detection: Trendlines are calculated using "Right-Side Clearance." A line is only drawn if the path from the anchor to the new pivot is unobstructed by price action.
Signal Protection: "Watch" and "Near" signals are suppressed during the decline phase (Left Side). They only appear once the "Bottom" (L1) has been confirmed and price is recovering on the Right Side.

5. Proximity Alerts & Breakouts
Watch Zone (Green Triangle): Appears when the Low of the bar is within 8% (configurable) of a valid trendline.
Near Zone (Yellow Triangle): Appears when the Low of the bar is within 4% (configurable) of a valid trendline.
Breakout Stop: Trendlines are dynamic. The moment a bar closes above a trendline, the line stops extending immediately, marking the exact breakout point.
How to Use This Indicator
The Setup: Look for a stock in an uptrend (Price > 200 SMA).
The Construction: Wait for the script to identify the Base High (H1). As the price corrects and begins to recover, you will see Grey Dotted Lines appear, connecting the highs.
The Contraction: Watch for Nested Trendlines. If you see a second or third line form from a lower high (H2, H3), it indicates a tightening of price action (VCP).


Settings Configuration
Moving Averages
21 EMA, 50 SMA, 200 SMA: Built-in reference averages.

Base Settings
H1 Lookback: How many bars back the script looks to find the "Start" of the base (Default: 21). Increase this for longer-term bases.
Sub-High Pivot Bars: Controls the sensitivity of identifying internal highs (handles).
Max Base Depth: If the base drops more than this % (Default: 30%), the structure is considered failed and lines are removed.
Enable Nested Trendlines: Toggle ON to see internal VCP lines (H2, H3). Toggle OFF to see only the main H1 trendline.
Show Only Latest Line: Keeps the chart clean by removing older lines from the same anchor point.

Visuals & Signals

Near/Watch Zone %: Adjust the sensitivity of the Green/Yellow triangles.
Signal Size: Change the size of the triangle markers.

DISCLAIMER
This is an indicator, not a trading system. Apply good risk management and do your own due diligence before putting your hard earned money into anything.
This script is for educational and analytical purposes only. It does not constitute financial advice. Automated pattern recognition has limitations and should always be verified visually.

Отказ от ответственности

Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.