ABCD Pattern Finder**Detailed Indicator Description**
Your indicator is an **ABCD Pattern Finder** for TradingView. It scans price action for swing-based **AB=CD harmonic-style patterns**, confirms whether the pattern meets your rules, then plots the pattern and related trade levels directly on the chart.
**Core Purpose**
The indicator is designed to find situations where price makes:
**A to B:** an initial impulse move.
**B to C:** a retracement or pullback.
**C to D:** a second move that is approximately equal to the A-to-B move.
When the C-to-D leg completes and passes the filter rules, the indicator treats point **D** as the trade-confirmation area. It then displays an entry reference, stop loss, and three take-profit levels.
**Bullish and Bearish Logic**
A **bullish setup** is one where the completed pattern suggests a potential long trade after point D.
A **bearish setup** is one where the completed pattern suggests a potential short trade after point D.
The indicator uses the sequence of highs and lows to decide whether the pattern is bullish or bearish. It does not simply mark every four-point swing; the swing sequence must form a valid ABCD structure.
**Zigzag Inputs**
**Pivot Bars Left** controls how many bars to the left must be considered when confirming a swing high or swing low.
**Pivot Bars Right** controls how many bars to the right must pass before a pivot is confirmed.
Higher values make the indicator less sensitive and produce fewer patterns. Lower values make it more sensitive and produce more patterns, but with more noise.
**Pattern Quality Inputs**
**Min CD/AB Time Ratio** sets the minimum amount of time the CD leg must take compared with the AB leg. This prevents CD from forming too quickly.
**Max CD/AB Time Ratio** sets the maximum amount of time CD can take compared with AB. This prevents slow, dragged-out CD legs from qualifying.
**AB=CD Equality Tolerance** controls how close the CD leg must be to the AB leg in price size. A value of **0.10** means CD can be within plus or minus 10% of AB.
**Min BC Retracement of AB** sets the shallowest acceptable pullback from B to C.
**Max BC Retracement of AB** sets the deepest acceptable pullback from B to C.
**Min AB Size ATR Multiple** requires the AB leg to be large enough compared with ATR. This helps filter out small, low-quality patterns.
**ATR Length** controls the ATR calculation used for volatility-based filtering and stop placement.
**Disallow Pattern Overlap** prevents a new pattern from being confirmed inside the range of an already confirmed pattern.
**Trade Inputs**
**Stop ATR Buffer Beyond D** places the stop loss beyond point D by a volatility-based buffer. A larger value gives the trade more room, while a smaller value creates a tighter stop.
**TP1 Fibonacci Level** sets the first profit target based on the A-to-D range.
**TP2 Fibonacci Level** sets the second profit target.
**TP3 Fibonacci Level** sets the third profit target.
The default target structure is TP1 at **0.618**, TP2 at **1.0**, and TP3 at **1.382** of the A-to-D range.
**Display Inputs**
**Trade Display Bars Forward** controls how far the entry, stop, and target lines extend to the right of the current candle.
**Show Trade Levels** turns entry, stop loss, and target lines on or off.
**Show ABCD Lines** turns the A-B, B-C, and C-D pattern lines on or off.
**Show ABCD Labels** turns the A, B, C, and D labels on or off.
You can also customize colors for the confirmed pattern, entry line, stop line, and target lines.
**Historical Pattern Inputs**
**Show Historical AB=CD Patterns** controls whether older confirmed patterns remain visible.
**Historical Closed Lookback** controls how many recently closed patterns are included in the historical visual/stat window.
**Closed Trade Lookback** lets you visually rewind and highlight a previous closed trade. A value of **0** shows the most recent trade. A value of **1** shows the trade before that.
**Closed Trade Lookback Color** controls the color used when reviewing an older closed trade.
**Confirmation Triangles**
The indicator can plot a triangle when a pattern is confirmed.
A bullish confirmation uses the bullish triangle color.
A bearish confirmation uses the bearish triangle color.
You can turn these triangles on or off and choose their size: **Tiny, Small, Normal, or Large**.
**AD Line Inputs**
The indicator can draw a line from point **A** to point **D**, extended to the right.
You can control whether this line appears, plus its color, width, and style: **Solid, Dashed, or Dotted**.
**Stats Window**
The stats window displays historical performance for TP1, TP2, and TP3.
For each target, it shows:
**Wins:** how many closed trades reached that target.
**Closed:** how many closed trades were evaluated.
**Rate:** the win rate for that target.
The stats are recalculated using your current trade input settings, so changing stop or target values updates the displayed historical results.
**Alerts**
The indicator includes two alerts:
**New ABCD Pattern Detected** triggers when a valid pattern is found.
**ABCD Pattern Entry at D** triggers when the pattern confirmation/entry condition occurs at point D.
Pine Script® indicator





