OPEN-SOURCE SCRIPT
Aggiornato

Fractal Trendlines

1 432
Fractal Trendlines is a non-repainting market structure indicator that builds dynamic support and resistance trendlines directly from confirmed fractal pivots. The script identifies major swing highs and lows using customizable left/right fractal strength settings, then connects those pivots into active trendlines while filtering out structurally weak lines using an optional Verified Trendlines mode. Verified red trendlines require lower highs and verified green trendlines require higher lows, helping remove a large amount of noisy or directionless structure.

The indicator is designed to separate short-term fractal structure from larger directional trend structure. Fractal markers and short pivot lines help visualize local reaction zones and recent liquidity pivots, while the trendline engine focuses on broader structural continuation and breakout behavior. Fractal Historical Lookback controls only the visible fractal markers and pivot lines without affecting the internal pivot memory used by the trendline engine. This allows traders to maintain a clean chart visually while still preserving deeper structural trendline calculations internally.

Break signals trigger only on currently active displayed trendlines. Once a trendline has produced a valid break signal, it becomes inactive and cannot generate repeated break labels. Break labels are directly tied to their parent trendline, so when older trendlines are removed by the Max Trendlines setting, their associated break labels are automatically removed as well. This prevents stale signals from remaining on the chart and keeps the display focused on current actionable structure.

The indicator can be used across multiple timeframes and trading styles. Lower fractal settings produce faster and more reactive structure, while higher settings produce cleaner swing-based trendlines more suitable for swing trading and macro structure analysis. RSI confirmation is optional and can be enabled to filter fractals using momentum conditions. Default settings are optimized for clean chart structure with minimal visual clutter while still retaining enough context for breakout and trend continuation analysis.
Note di rilascio
This update adds a new user input called Minimum Pivot ROC %, allowing traders to control the minimum percentage price movement required between connected pivots before a verified trendline can be drawn. Increasing the value filters out weaker or flatter trendlines, while lower values allow more aggressive structural sensitivity and trendline generation.

Additional minor refinements were also made to default settings and overall chart cleanliness while preserving the indicator’s non-repainting fractal logic and active trendline break system.
Note di rilascio
Improved the Trendlines settings panel layout and added inline documentation.

- Reordered the Trendlines group so structural settings (extend and max trendlines) appear before directional and style options
- Added tooltip to **Use Verified Trendlines Only** explaining how verified mode filters for structurally valid pivots and its relationship to the ROC threshold
- Added tooltip to **Minimum Pivot ROC %** clarifying its role and that it is only active when verified mode is enabled

No logic changes.
Note di rilascio
# Fractal Trendlines — What's New vs The Original

---

## **What Stayed Exactly The Same**

Every single feature from the original is untouched — fractal detection, pivot lines, fractal markers, RSI confirmation, historical lookback, verified trendline logic, ROC% filtering, primary trendline drawing, max trendlines, break signals, break labels, alerts, and all existing user controls behave identically.

---

## **What's New — The Addon Trendlines System**

A brand new section called **"Addon Trendlines"** now appears in the indicator settings. This is a completely separate, optional layer that sits on top of the existing system without interfering with it in any way.

### **The Core Idea**

Every time the indicator draws a new primary trendline between two fractal pivots, it remembers the **left anchor point** of that line — the starting pivot. The addon system then watches for every subsequent qualifying fractal that appears after that anchor and draws an additional line from that same fixed starting point to each new qualifying pivot.

Think of it like a fan of lines all radiating out from the same origin point, each one connecting that origin to a newer and newer fractal as the market develops. When the primary trendline resets to a new pair of pivots, the entire fan clears and starts fresh from the new anchor.

---

## **The New User Controls**

All addon controls live under the new **"Addon Trendlines"** group in settings.

- **Show Addon Trendlines** — The master toggle for the entire addon system. Off by default. Turning this on activates the fan of additional lines from the current anchor pivot. Addon lines are never drawn on top of the primary trendline — they only appear on subsequent qualifying fractals after the primary line has already been established.

- **Addon High Trendline Color** — Controls the color of addon lines drawn from fractal highs (the resistance side). Defaults to a faded/transparent red so it's visually distinct from the solid primary red lines but clearly related.

- **Addon Low Trendline Color** — Controls the color of addon lines drawn from fractal lows (the support side). Defaults to a faded/transparent green for the same reason.

- **Show Addon Break Signals** — A separate toggle that enables break detection on the addon lines. Off by default. When turned on, the indicator watches for price closing through any unbroken addon line and fires a label when it does — exactly like the primary break signal system.

- **Addon Bull Break Label Color** — The background color of the break label when price breaks upward through an addon resistance line. Defaults to light green.

- **Addon Bull Break Text Color** — The text color inside the bull addon break label. Defaults to black.

- **Addon Bear Break Label Color** — The background color of the break label when price breaks downward through an addon support line. Defaults to pink.

- **Addon Bear Break Text Color** — The text color inside the bear addon break label. Defaults to white.

---

## **Default Label Colors At A Glance**

- Primary bull break — lime background, black text
- Primary bear break — red background, white text
- Addon bull break — light green background, black text
- Addon bear break — pink background, white text

---

## **How The Addon System Behaves**

- Addon lines use the **same style, width, and extension settings** as the primary trendlines — so if your primary lines are dashed and extended to the right, addon lines will be too.
- Addon lines respect the **same ROC% and verified trendline rules** as the primary lines — a new fractal only gets an addon line if it passes the same slope and direction filters.
- **All addon lines from a given anchor are visible simultaneously** — they accumulate as new qualifying pivots form, creating a fan effect from the same origin point.
- The **first fractal that establishes a new primary line is never duplicated** as an addon line — addon lines only appear on fractals that come after the primary line is already drawn.
- When the **anchor resets** — meaning a new primary trendline forms with a new left pivot — all previous addon lines and any break labels on them are deleted automatically.
- **Addon break signals fire independently** of primary break signals and will never appear on the same bar as a primary break — if a primary break fires first, addon break detection is skipped for that bar entirely.
- Addon break labels use the **same break text** defined in the main Break Signals group ("BREAK ↑" and "BREAK ↓" by default), just in the addon color scheme to distinguish them.
- The addon break label size follows the **same Break Label Size setting** as the primary break labels.
Note di rilascio
Internal defaults adjusted for improved user experience.
Note di rilascio
Internal bug fixes.
No change to current inputs or logic.
Note di rilascio
Added to additional alert options:
1. New Bull Trendline
2. New Bear Trendline
Note di rilascio
Minor input heading updates to be more intuitive.
Internal defaults updated for improved user experience.
Note di rilascio
**Update Description**

This update adds a new **Hi/Lo Mode** setting to the fractal engine.

The purpose of this setting is to let the user choose how fractal pivots are detected:

When **Hi/Lo Mode is ON**, the indicator works the same way it did before. It looks for fractal highs using candle highs and fractal lows using candle lows. This is the classic wick-based method.

When **Hi/Lo Mode is OFF**, the indicator detects fractals using candle closes instead. This makes the structure less sensitive to long wicks, stop hunts, and temporary intrabar spikes.

---

**New User Input**

**Hi/Lo Mode**

Default: **On**

Location: **Fractals section**, directly under **Non-Repaint Signals**

Tooltip:

> When enabled, fractals are detected using candle highs and lows. When disabled, fractals are detected using candle closes instead, which can reduce wick-based pivots and produce cleaner structure.

---

**What It Changes**

This does not simply change the break signal logic.

It changes the actual fractal structure used to build:

* fractal markers
* pivot lines
* main trendlines
* addon trendlines
* breakout/breakdown detection

Because trendlines are built from fractal points, changing the fractal source changes the geometry of the entire indicator.

---

**Hi/Lo Mode ON**

This is the default behavior.

The indicator uses:

* candle highs to find high fractals
* candle lows to find low fractals

This mode is more reactive and captures full price extremes.

Best for:

* aggressive traders
* intraday charts
* volatile markets
* wick-based structure
* early pivot detection

Tradeoff:

It may create more pivots from temporary price spikes.

---

**Hi/Lo Mode OFF**

The indicator uses candle closes to identify both high and low fractals.

This means a candle must close at a meaningful relative level to qualify as a fractal pivot.

Best for:

* cleaner structure
* swing trading
* reducing wick noise
* avoiding false pivots from stop runs
* smoother trendline behavior

Tradeoff:

Signals may appear later or less often, but the structure is generally cleaner.

---

**Blunt Summary**

This is a worthwhile upgrade.

**Hi/Lo Mode ON** gives you the original, faster, wick-sensitive behavior.

**Hi/Lo Mode OFF** gives you a cleaner close-based structure filter.

The default being **ON** is correct because it preserves the existing indicator behavior unless the user chooses otherwise.
Note di rilascio
**What Changed**

The script now keeps the chart cleaner by only showing fractal markers and short pivot lines on pivots that are actually being used by visible trendlines.

Before, the fractal visuals could appear on more pivots than expected. Now they are tied directly to the lines that are being drawn.

**Main Trendline Visuals**

The original fractal marker and pivot line controls still apply to the main trendlines only.

These inputs control main trendline endpoints:

**Show Fractal Markers**
Turns main trendline endpoint triangles on or off.

**Show Fractal Pivot Lines**
Turns the short horizontal pivot lines on or off for main trendline endpoints.

**Pivot Line Length**
Controls how far the main short pivot lines extend to the right.

**High / Low Pivot Line Color**
Controls the colors for main high-pivot and low-pivot lines.

**Pivot Line Width**
Controls the thickness of main pivot lines.

**Pivot Line Style**
Controls whether main pivot lines are solid, dashed, or dotted.

**New Addon Visual Controls**

Addon trendlines now have their own separate visual controls. They no longer have to share the main fractal settings.

**Show Addon Fractal Markers**
Turns triangle markers on or off for addon trendline endpoints only.

**Show Addon Fractal Pivot Lines**
Turns short horizontal pivot lines on or off for addon trendline endpoints only.

**Addon Pivot Line Length**
Controls how far addon pivot lines extend to the right.

**Addon High Pivot Line Color**
Controls the color of addon pivot lines connected to high pivots.

**Addon Low Pivot Line Color**
Controls the color of addon pivot lines connected to low pivots.

**Addon Pivot Line Width**
Controls addon pivot line thickness.

**Addon Pivot Line Style**
Controls whether addon pivot lines are solid, dashed, or dotted.

**Practical Result**

You now have full independent control:

Main trendline endpoint visuals can be on while addon visuals are off.

Addon endpoint markers can be on while addon pivot lines are off.

Addon pivot lines can have different colors, width, length, and style from the main pivot lines.

The chart should stay much cleaner because visuals are only tied to actual displayed line endpoints.
Note di rilascio
## Change Log – ATR-Confirmed Trendline Break Signals

### New Feature: ATR Break Confirmation Filter

Added a new ATR-based confirmation filter for trendline break signals. This enhancement helps reduce false breakouts by requiring price to move a user-defined ATR distance beyond a trendline before a break signal is generated.

### New Inputs

The following inputs have been added to the **Break Signals** group:

* **Break ATR Length**

* Controls the ATR calculation period used for break confirmation.

* **Break ATR Cutoff**

* Defines the minimum ATR-based distance price must close beyond a trendline before a break signal is triggered.
* Default value: **0.25**
* A value of **0.00** disables the ATR filter and restores the original break behavior.

### Break Logic Enhancement

Trendline breaks now use ATR-adjusted confirmation levels when the ATR filter is enabled.

Bullish breaks require price to close above:

* Active trendline value
* Plus the ATR cutoff distance

Bearish breaks require price to close below:

* Active trendline value
* Minus the ATR cutoff distance

### Multi-Bar Confirmation Behavior

ATR confirmation is no longer required on the initial trendline crossover candle.

If price crosses a trendline but does not yet satisfy the ATR threshold:

* No break label is generated.
* No break alert is triggered.
* The trendline remains active.
* The script continues monitoring subsequent candles.

The break signal is generated on the first candle that successfully closes beyond the ATR confirmation threshold.

This prevents valid breakouts from being missed when the breakout develops over multiple candles.

### Non-Repaint Compatibility

ATR-confirmed break signals fully respect the existing Non-Repaint Signals setting.

When enabled:

* ATR break signals are confirmed only after candle close.
* Labels are plotted only on confirmed candles.
* Alerts are triggered only on confirmed candles.
* No intrabar ATR break signals are generated.

When disabled:

* ATR break signals may appear intrabar as soon as the ATR threshold is exceeded.
* Signals may change before candle close.

### Applies To

The ATR confirmation filter is applied to:

* Main bullish trendline break signals
* Main bearish trendline break signals
* Addon bullish trendline break signals
* Addon bearish trendline break signals
* Break labels
* Break alerts

### Unchanged Functionality

This update does not modify:

* Fractal detection
* RSI confirmation
* Trendline construction
* Trendline validation
* Addon trendline generation
* Fractal markers
* Pivot lines
* Trendline appearance settings

All existing trendline creation and visualization logic remains unchanged.

### Default Configuration

Recommended default settings:

* Break ATR Length: 14
* Break ATR Cutoff: 0.25

These values provide additional breakout confirmation while remaining responsive enough to capture legitimate trendline breaks in a timely manner.
Note di rilascio
**Fractal Trendlines — Update Notes**

This update replaces the old on/off toggle for extending trendlines with a three-option dropdown that gives you precise control over how far each trendline travels across the chart. The goal was to reduce visual clutter and make the chart reflect only what's actually meaningful at any given moment.

**What changed**

The previous "Extend Trendlines Right" checkbox was a binary choice — lines either ran forever to the right edge or stopped dead at the second fractal pivot. That's fine for simple use cases, but it meant there was no middle ground. The new dropdown replaces that checkbox entirely and gives you three distinct behaviors to choose from.

**The new input: Extend Trendlines**

Located in the Trendlines settings group, this dropdown has three options:

- **Chart Edge** — This is the equivalent of the old toggle being switched on. Once a trendline is drawn between two fractal pivots, it projects forward indefinitely across the entire chart. Useful if you want to see where a trendline would sit far into the future or against distant price history.

- **Fractal** — The trendline is drawn only between its two defining pivot points and goes no further. It starts at the first fractal and ends exactly at the second. Nothing extends beyond those two anchors. This is the cleanest option visually and works well when you care more about identifying the pivot structure than tracking where the line projects.

- **Break** — This is the most dynamic option. Each trendline starts by extending to the right edge, exactly like Chart Edge mode, and continues projecting forward as price develops. The moment price breaks through the line by the required ATR distance, the line is immediately capped — it stops and ends precisely at the break bar, right on the trendline's own projected price at that point. Lines that haven't been broken yet continue extending normally. This keeps the chart clean by retiring lines the moment they're no longer valid, while still showing the full projection of any trendline that remains intact.

This behavior applies consistently across both the main trendlines and the addon trendlines, so everything on the chart follows the same rule.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.