OPEN-SOURCE SCRIPT
Atualizado

ABCD Pattern

1 647
The ABCD Pattern indicator automatically detects and draws classic harmonic ABCD structures on any instrument and timeframe. The pattern consists of four alternating swing points — A, B, C, D — where the price action forms two consecutive price legs with a retracement between them, validated using Fibonacci ratios.

Pattern Structure

A bullish ABCD begins at a swing high (A), retraces to a swing low (B), rallies to a swing high (C) below A, then drops to a swing low (D) where the reversal is expected. A bearish ABCD mirrors this logic starting from a swing low.

The indicator uses an alternating pivot buffer that enforces strict alternation between highs and lows. When a new pivot is detected that matches the existing direction, it replaces the current pivot rather than creating a new leg — this ensures only clean, well-defined structures are tracked.

Fibonacci Validation

For a pattern to qualify, two conditions must be met simultaneously:

BC/AB retracement: the BC leg must retrace between 50% and 88.6% of the AB leg
CD/BC extension: the CD leg must extend between 113% and 161.8% of the BC leg
Both ranges are fully configurable from the inputs panel. Tightening the ranges produces fewer, higher-quality signals. Widening them detects more patterns with looser Fibonacci alignment.

PRZ — Potential Reversal Zone

Before the D point is confirmed, the indicator projects a D zone box onto the chart in real time. This box is calculated from the current C pivot using the configured Fibonacci extension range, giving the trader a visual target area to watch. The moment D is confirmed by the pivot lookback, the PRZ box closes at the D bar and the full zigzag is drawn.

Visual Output

When a pattern completes, the indicator draws:

Three connecting lines across the A→B→C→D zigzag (A→B and B→C in a lighter shade, C→D in full color)
Labels at each pivot point: A, B, C, and D with a directional arrow (↑ bullish, ↓ bearish)
A triangle signal shape below/above the D bar for quick visual scanning
Bullish patterns are shown in green, bearish in red. Both colors are fully customizable.

MTF Dashboard

A compact table in the top-right corner displays the last ABCD signal direction across three independently configurable timeframes using request.security(). Each cell shows ▲ (last signal was bullish) or ▼ (last signal was bearish), color-coded green or red. Signals older than a configurable number of bars are shown as neutral (grey) to avoid acting on stale context.

Settings

Left/right bars: controls pivot sensitivity (default 5/5)
BC/AB min and max retracement ratios
CD/BC min and max extension ratios
PRZ width in bars
Toggle: PRZ box, labels, zigzag lines, MTF dashboard
Bullish/bearish colors
Three MTF timeframes + stale threshold
No repainting. All signals fire only after the D pivot is fully confirmed by the right-bar lookback. Compatible with any plan — does not require premium features.
Notas de Lançamento
WHAT THIS IS
An ABCD is three confirmed swings and a fourth that has to land inside a Fibonacci window. Most scripts draw the shape once all four points exist — which is a drawing, not a signal, because by then the move you would have traded has already happened.

This one projects the fourth point before it exists, marks the completed pattern on the bar it actually completed on, and filters out the ones too small to be structure.

1. THE D ZONE IS PROJECTED, NOT REPORTED
As soon as A, B and C are confirmed, the region where D must complete is already determined: it is the CD extension measured off the BC leg. The script draws that zone ahead of price.

That zone is the only part of an ABCD you can act on. Everything drawn after D has printed is a record of what happened.

The zone updates as new swings confirm, and disappears when the last three pivots stop forming a valid ABCD leg structure — it does not linger as decoration once the setup it described is gone.

2. THE PATTERN IS MARKED WHERE IT HAPPENED
A swing low is only confirmed a number of bars after it forms — that is what makes a pivot a pivot, and it is why nothing here repaints.

The consequence is that the completing swing of an ABCD is recognised late. Scripts that plot a shape on the bar the pattern was detected put the arrow several bars to the right of the point it refers to, so the labels say one thing and the marker points somewhere else.

Here the labels, the zigzag legs and the triangles are all drawn on the bar they belong to.

3. SIGNIFICANCE FILTER
The Fibonacci windows are wide by nature — a BC retracement anywhere from 50% to 88.6% is most of the plausible range. Without a size filter, every minor wiggle on the chart satisfies the geometry and the chart fills with patterns spanning less than an average candle.

Minimum AB leg (× ATR) judges the reference leg of the pattern against current volatility. Raise it until only the swings you would have drawn by hand survive. This is the setting that decides whether the output is usable.

4. MULTI-TIMEFRAME DASHBOARD
A compact table shows the most recent ABCD direction on three timeframes of your choosing, and whether it is still recent enough to matter.

A column greys out to – when its last pattern is older than the staleness threshold, so an ABCD from two hundred bars ago does not sit there implying it is still in play.

The threshold is counted in bars of that timeframe: 50 on the H4 column means 50 four-hour bars, not 50 chart bars. That is usually what you want from a higher-timeframe column, but it is worth knowing before you read the row.

SETTINGS
Left / Right bars — pivot strength. Higher gives fewer and larger swings, and more delay before a pattern is confirmed.
BC/AB retracement min and max — how deep B to C must pull back. Defaults 0.50 to 0.886.
CD/BC extension min and max — how far D must extend beyond C. Defaults 1.13 to 1.618.
Minimum AB leg (× ATR) — the size filter described above.
PRZ width — how far right the projected zone is drawn.
Three dashboard timeframes and the staleness threshold.
Zigzag lines, labels, the projected zone and the dashboard can each be switched off.

ALERTS
Three conditions: bullish ABCD completed, bearish ABCD completed, and either. All fire on completion, once per pattern.

LAG, STATED
Nothing repaints, and that costs you. A pivot is confirmed Right bars after it forms, so a completed ABCD is recognised that many bars after D printed. The projected D zone does not have this problem — it is built from pivots that were already confirmed, which is precisely why it is the useful half of the tool.

WHAT THIS DOES NOT DO
It does not tell you to buy or sell at D, and it makes no claim about how often price reverses there. Geometry that fits a Fibonacci window is not evidence of anything on its own, and whether these setups survive real spread and commission on your instrument is a question this tool does not answer and does not pretend to.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.