OPEN-SOURCE SCRIPT
Обновлено

ABC Breakout

2 722
ABC Breakout detects bullish and bearish ABC retracement structures using adaptive pivot-based market structure and configurable retracement ratios. The indicator confirms setups only after price closes beyond point B, then automatically plots the entry, stop loss, and TP1 / TP2 / TP3 targets using customizable risk-reward settings.

The main inputs allow you to control pivot sensitivity, valid ABC retracement depth, overlap filtering, trade target ratios, historical pattern visibility, and confirmation display settings. Lower pivot settings produce faster and more frequent setups, while higher settings filter noise and focus on larger structure moves. The ABC ratio inputs help define how shallow or deep the C-point retracement must be before a setup becomes valid.

Use the indicator to trade continuation breakouts after pullbacks during trending conditions. Pending ABC structures can repaint or disappear while pivots are still developing because swing confirmation requires future candles. Once a breakout candle closes and the setup becomes confirmed, the pattern and trade levels are locked and do not repaint. The built-in stats window tracks how often TP1, TP2, and TP3 are reached before stop loss across closed trades, allowing traders to evaluate performance across different markets and timeframes.
Информация о релизе
Added optional pending pattern invalidation logic to improve structural quality of unconfirmed ABC setups. When enabled, pending bullish patterns are invalidated if a confirmed candle closes below the active C pivot before price confirms the setup by breaking B. Pending bearish patterns are invalidated if a confirmed candle closes above C before confirmation. The update preserves normal pivot repainting and adaptive C formation as long as updated pivots remain within the configured ABC ratio parameters. Confirmed patterns, trade management, and historical statistics behavior remain unchanged.
Информация о релизе
Added user functionality...
Added a user toggle checkbox to turn ABC labels on/off.
Информация о релизе
Updated alert functionality for the ABC Breakout indicator.

This update adds three dedicated TradingView alert conditions so users can create separate alerts for each major pattern event:

1. **New ABC Pattern Detected** — triggers when a valid pending ABC pattern is identified.
2. **ABC Pattern Invalidated** — triggers when a pending ABC setup is invalidated by a confirmed close beyond the C pivot.
3. **ABC Breakout Confirmed** — triggers when price confirms the breakout beyond the B/entry level.

This change improves alert management by allowing users to choose specific alert types directly from TradingView’s alert condition menu instead of relying only on a single general script alert. No changes were made to the indicator’s pattern detection logic, trade level calculations, visual display settings, historical pattern handling, or statistics table.
Информация о релизе
Added indicator Title Name to Stats Info Box.
Информация о релизе
Added a Minimum ATR filter for AB leg.
User can now specify the minimum ATR size of the AB leg.
This is useful for filtering out noise level ABC formations.
Информация о релизе
This update adds an optional AC trendline to the indicator — a straight line projected from pivot A through pivot C and extended forward to the right.

The AC line acts as a dynamic support or resistance reference, giving you a visual read on the slope and angle of the overall ABC structure. It is intentionally subdued by default so it complements rather than competes with the core pattern drawing.

**Behavior**

The AC line only appears on the active confirmed trade. It will not appear on pending or historical patterns. If you are using the Open Trade Lookback feature to review a prior setup, the AC line will display for whichever pattern is selected — consistent with how trade levels and the pattern drawing behave in that mode.

**Controls** — found in the *AC Line* settings group:

- **Show AC Line** — toggles the feature on or off
- **AC Line Color** — defaults to blue
- **AC Line Width** — line thickness from 1 to 4, defaults to 2
- **AC Line Style** — Solid, Dashed, or Dotted, defaults to Dotted
Информация о релизе
**Update — ABC Structure Validation Fix**

**What Was Wrong**

The indicator could incorrectly identify a bearish ABC pattern as a bullish signal and fire a buy confirmation triangle on a downward structure. The logic determining bull vs bear direction was flawed and didn't properly account for the shape of the pattern.

**What Was Fixed**

Added proper structural validation for both bull and bear patterns.

A valid **bullish ABC** now requires the AB leg to move upward, with C retracing partially downward but staying above A.

A valid **bearish ABC** now requires the AB leg to move downward, with C retracing partially upward but staying below A.

**What Was Not Changed**

The user-defined retracement ratio inputs work exactly as before and apply correctly to both bull and bear structures. Entry, stop, and target logic are also unchanged.

**Net Result**

Bull and bear signals now only fire on properly formed ABC structures, eliminating the false directional signals that could appear on the previous version.
Информация о релизе
## **What Changed From the Original**

Three bugs were fixed and one setting was renamed.

---

### **Bug Fix 1 — Rewind Skips the Current Open Trade**

When you had an active open trade running and set the lookback to 1, the indicator would land on that open trade instead of skipping past it to the previous closed one. It only knew to skip a pending (unconfirmed) pattern, not a live confirmed trade. Now it correctly skips both — so regardless of whether you're sitting on a pending setup or an active open trade, the rewind always starts counting from the most recent *closed* trade backward.

---

### **Bug Fix 2 — Rewind Numbers Are Now Strictly Closed-Trade-Relative**

Even after the first fix, the rewind counter was still just stepping backward through all trades in order — open or closed — which could cause it to land on a trade that hadn't finished yet. Now the counter only increments when it finds a trade that has already closed. Open trades are completely invisible to it. So 1 always means the most recently closed trade, 2 always means the one before that, with no exceptions.

---

### **Bug Fix 3 — Normal View at 0 Is More Reliable**

The normal view (lookback set to 0) now explicitly finds the current live trade by checking its actual state rather than assuming its position. A minor robustness improvement with no visible difference under normal conditions.

---

### **Rename — "Open Trade Lookback" → "Closed Trade Lookback"**

The setting and its color option were renamed to accurately reflect what they do. You're rewinding through closed trades, so the name now says exactly that.

---

## **How to Use the Controls**

**Closed Trade Lookback** — set this to `0` for normal use. The indicator shows whatever is happening right now: an active trade with its entry, stop, and take profit levels drawn out, or a pending unconfirmed setup waiting for breakout.

Set it to `1` to hide the current setup and instead review the most recently closed trade — the last one that hit either its stop or its final target. Its pattern lines highlight in the Closed Trade Lookback Color and its levels extend forward so you can study the setup clearly. Set it to `2` for the one before that, `3` for the one before that, and so on.

Any trades older than the one you're viewing continue to show in the historical color as background context, so you always know where the selected trade sits in the broader sequence.

**Closed Trade Lookback Color** — the highlight color applied to whichever closed trade the rewind is pointing at. Defaults to red to keep it visually distinct from everything else on the chart.
Информация о релизе
Here's a full description of what changed and what's new.

---

**Overview**

The original indicator had one way to trade an ABC pattern — wait for price to break back through the B pivot, then enter with fixed risk/reward targets. The update adds a second approach called FIB Mode, which is a completely different trading philosophy. Both modes share the same pattern detection engine. Everything that changes is about how and when you enter, where your stop goes, and where your targets sit.

---

**What Stayed Exactly the Same**

Pattern detection is identical in both modes. The zigzag, pivot detection, ABC validation, ratio filter, ATR size filter, overlap prevention, and invalidation on close beyond C in the pending state — all unchanged. The stats window, historical pattern display, closed trade lookback, confirmation triangles, AC line, and all visual settings work identically regardless of which mode you're in.

---

**Original Behavior — now called ATR Mode**

When a valid ABC forms, the indicator waits. The pattern sits as pending (yellow) until price closes beyond the B pivot in the direction of the trade. That close beyond B is the confirmation signal. At that point:

- **Entry** is at the B pivot price
- **Stop** is at the C pivot price
- **Targets** are multiples of the BC risk distance — TP1 at 0.5R, TP2 at 1R, TP3 at 2R by default

The risk/reward ratios are fully adjustable. This is a momentum-confirmation approach — you're not entering until the market has proven it wants to go your direction.

---

**New Behavior — FIB Mode**

When FIB Mode is enabled, the indicator no longer waits for a close beyond B. Instead, the moment C is confirmed as a valid pivot, the trade triggers immediately. There is no pending state — every valid ABC that forms becomes a live trade.

- **Entry** is the closing price of the bar that confirmed C as a valid pivot. Because the pivot detection requires a certain number of bars to the right of C before it can declare it a pivot, the entry bar is always that many bars after C actually formed. The default is 5 bars to the right, so you're entering 5 bars after C peaked or troughed.
- **Stop** is the high of the C bar for a bearish trade, or the low of the C bar for a bullish trade. This is the structural invalidation level — if price trades back through the extreme of the C pivot bar, the pattern is broken.
- **Targets** are Fibonacci extensions of the AB leg projected from B. TP1 defaults to 100% of AB from B, which is essentially a return to the A pivot area. TP2 defaults to 127.2% and TP3 to 161.8%, which are the standard harmonic extension levels beyond B.

All three target levels are fully adjustable inputs.

---

**New Inputs Added**

**Trade Mode group:**
- FIB Mode checkbox — off by default, preserving original behavior

**ATR Mode group** (renamed from Trade, same settings as before):
- TP1, TP2, TP3 risk/reward ratio inputs — unchanged from original

**FIB Mode group:**
- TP1 Fib Extension — default 1.000
- TP2 Fib Extension — default 1.272
- TP3 Fib Extension — default 1.618

---

**Key Behavioral Differences**

In ATR mode, many detected patterns never confirm — they sit pending and either invalidate or eventually trigger. In FIB mode every valid pattern confirms immediately, so you will see more confirmed trades.

In ATR mode the stop is always at C, giving you a risk distance equal to the full BC move. In FIB mode the stop is tighter — it's the C bar's extreme, not the C pivot price, and your entry is somewhere between C and B, so the risk distance is smaller.

In ATR mode targets are mechanical multiples of your risk. In FIB mode targets are structural — derived from the geometry of the pattern itself, specifically how far AB moved and projecting that from B.

The invalidation logic for pending patterns is disabled in FIB mode because there is no pending state to invalidate.
Информация о релизе
Fibonacci extensions in FIB mode internal defaults and minimums updated.
No change to internal logic.
Информация о релизе
Internal Defaults adjusted for improved user experience.
Indicator code name updated for improved searchability (short name remains the same).
Информация о релизе
# Change Log — ABC Breakout Pattern Finder

## 1. Fixed the FIB Mode entry price calculation

**The problem:** When FIB Mode was turned on, the script was supposed to set the trade entry price to the closing price of the "C" pivot candle — the third point in the ABC pattern. That's exactly what the tooltip in the settings panel described. But the actual code wasn't doing that. Instead, it was using the closing price of whichever candle happened to be processing at the moment the pattern was detected.

**Why that's a problem:** Pattern detection doesn't happen the instant a pivot forms. The script needs to see a handful of candles on either side of a high or low point before it can confirm that point as a real pivot (this is standard for pivot-based detection — you can't know something was a "high" until you've seen what came after it). That confirmation delay means several candles pass between when the C pivot actually happens and when the script recognizes it. So the entry price was being pulled from a candle that came *after* the real C pivot, not from the C pivot itself.

**The fix:** The entry price now correctly references the closing price of the actual C pivot candle, using a lookback calculation that finds the right historical bar rather than just using the current one.

**Why it matters:** This isn't a cosmetic detail — it changes the actual price level the strategy considers a valid entry point. Since stop-loss and take-profit levels in FIB Mode are calculated relative to structural points (not relative to the entry itself), the entry price being wrong mainly affected risk-per-trade sizing and the accuracy of the win-rate statistics table, since those stats track outcomes relative to when a trade is considered "confirmed."

## 2. Wired up a calculation that existed but was never used

**The problem:** The correct value — the C pivot candle's closing price — was actually already being calculated elsewhere in the code. It was sitting there fully computed and ready to use, but nothing ever referenced it. Meanwhile, a separate, incorrect calculation was being used instead for the entry price.

**The fix:** The already-calculated correct value is now the one actually feeding into the entry price logic described in item 1 above. No new calculation was added — this was purely a matter of connecting a value that already existed to the place it should have been used all along.

## 3. Removed a dead, unused data structure

**The problem:** Near the top of the script, there was a data structure (an array) set up to hold "historical pattern drawings" — visual elements representing past ABC patterns on the chart. It was created once when the script started and then never referenced again anywhere in the rest of the code. Nothing was ever added to it, and nothing ever read from it.

**Likely origin:** This looks like it was part of an earlier approach to displaying historical patterns that was later replaced with a different, working method (the script now handles historical pattern visibility through a different mechanism entirely — toggling colors and visibility on existing drawings rather than maintaining a separate list). The old, unused piece was simply never cleaned up when the newer approach was built.

**The fix:** That unused structure has been deleted entirely.

**Why it matters:** This had zero effect on how the indicator actually behaves or displays anything — it was inert code taking up space. Removing it doesn't change any visual output, any signal, or any calculation. It's purely a housekeeping change that makes the script easier to read and slightly reduces memory overhead.

## 4. Eliminated unnecessary duplicate object creation

**The problem:** Every single time a new ABC pattern was detected on the chart, the script performed a small inefficiency: it created a full drawing-related object, attached it to the newly detected pattern, and then — just two lines of code later — immediately replaced that same object with a completely different one that was actually going to be used going forward. The first object was created and thrown away for no functional reason.

**Why it happened repeatedly:** Because this all occurs inside the core pattern-detection logic, which runs every time a new zigzag pivot is confirmed. On a long price history with many patterns, this wasteful step would have executed many, many times over.

**The fix:** The pattern is now built without creating that unnecessary throwaway object up front. It's initialized empty and then filled in exactly once with the object that's actually going to be used.

**Why it matters:** This is purely a performance and code-cleanliness improvement. It doesn't change what appears on the chart, what signals fire, or any calculated value — it just means the script does slightly less unnecessary work behind the scenes.

## What was intentionally left unchanged

One additional small redundancy was noticed but not touched: in one section of the code (the ATR Mode trade confirmation logic), a value used for extending drawing lines forward in time gets calculated, then calculated again a few lines later with the identical formula. Both calculations produce the exact same result, so this has no effect on behavior whatsoever — it's purely a leftover duplicate line. Since it doesn't cause any incorrect output, it was left in place rather than modified, to avoid making changes to working logic beyond what was specifically needed.

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

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