OPEN-SOURCE SCRIPT
Zaktualizowano

Fractal Support and Resistance Zones Engine

9 939
Fractal Support and Resistance Zones Engine is a market structure tool built to convert confirmed fractal pivots into filtered support, resistance, and S/R flip zones.

The main reason this script was created is practical rather than theoretical. Fractal highs and lows are already a familiar market structure concept, but many fractal-based tools become difficult to use once they start filling the chart with too many overlapping levels. When every pivot is treated as equally important, the result is often visual clutter, weak prioritization, and little help in deciding which areas still matter around current price.

This script was written to make that process more usable. Instead of simply marking fractal pivots, it manages them as zones with a lifecycle. It filters oversized zones, ignores zones that are too far from current price, merges overlapping structure, tracks repeated interaction, handles role reversal behavior, removes weak or aging zones, and then selects only the strongest visible candidates for display.

Why this indicator exists

This script does not claim to introduce a new theory of support and resistance. Its purpose is to provide a more structured implementation of a familiar concept.

The problem it tries to solve is straightforward:

raw fractal levels can accumulate too quickly,
overlapping levels can make the chart harder to read,
old or weak zones can remain on screen longer than they are useful,
and many simple fractal tools do not do much after the initial pivot is detected.

This indicator was built to address those issues by treating zones as dynamic objects instead of static drawings. Once a zone is created, it is managed over time based on interaction, break behavior, age, visibility ranking, and proximity to price.

That is the main reason the script was written. It is not meant to replace all support and resistance methods. It is meant to make fractal-based structure more organized and more practical to work with.

What the indicator does

The script detects confirmed fractal highs and lows using left and right pivot bars.

A confirmed pivot high can create a resistance zone.
A confirmed pivot low can create a support zone.

There is also an optional developing zone mode. When enabled, the script can show provisional zones before full pivot confirmation. These are intentionally temporary and may disappear if price invalidates them before confirmation.

After a zone is created, the script does not simply leave it untouched. It keeps evaluating that zone and updates its status over time.

The script can display three structural categories:

Resistance zones
Support zones
S/R flip zones, when a previously broken zone changes role
How the script works

The engine begins with fractal pivot detection.

For resistance, the zone is built from the pivot high area.
For support, the zone is built from the pivot low area.

From there, several control layers are applied:

1) ATR-based size control
Zone height is capped by an ATR multiple so unusually large candle ranges do not create oversized zones that dominate the chart. This helps keep zones more comparable and visually usable.

2) Minimum significance and maximum distance filtering
A new zone must still meet a minimum size requirement relative to ATR, and it must remain within the configured distance from current price. This prevents the script from storing zones that are either too small to matter or too far away to be useful in the current context.

3) Overlap and merge logic
If a newly detected zone overlaps with an existing one, the script does not always draw another separate zone. When the roles match, it can reinforce and blend the existing zone rather than duplicating structure. This is one of the main anti-clutter mechanisms in the script.

4) Touch tracking
Zones gain interaction history when price returns to them from outside and touches them again. This interaction history later contributes to ranking and lifecycle decisions. A zone that has been respected multiple times is treated differently from a fresh zone that has never been retested.

5) Break and S/R flip handling
When price breaks beyond a zone by a configurable ATR-based threshold, the script can treat that as a structural break. If retest confirmation is enabled, the zone does not immediately change role. Instead, it enters a waiting state and only flips after the retest condition is satisfied. If retest confirmation is disabled, the role change happens immediately on the break condition. This gives the user a choice between faster reaction and stricter confirmation.

6) Flip count and removal behavior
Zones are not allowed to survive forever in the same way. The script tracks flip count and interaction history. If a zone has already flipped multiple times, it can eventually be removed instead of continuing to recycle indefinitely. This prevents heavily reused or degraded structure from staying on the chart forever.

7) Age-based pruning
Zones are also removed as they get older. Stronger zones can survive longer because the lifespan is adjusted by interaction and flip history, but aging still matters. This helps the chart focus more on structure that is still relevant.

8) Spatially aware pool management
The script keeps a limited zone pool depending on the selected performance mode. When the internal pool gets too large, weaker zones are evicted using a score that considers relevance and local crowding. In practice, this means the engine is not only adding zones, but also actively managing what deserves to stay in memory.

9) Visibility ranking
The script scores zones using interaction history, flip history, distance from current price, and age. It then selects only the top visible resistance, support, and flip zones rather than showing everything at once. This is a key part of the workflow because the script is designed to prioritize readability, not maximum historical coverage.

What makes it different from simpler fractal indicators

The main difference is not the use of fractals themselves. Fractals are well known. The difference is what happens after the fractal is detected.

Many simpler scripts stop at the first step: they identify the pivot and draw a level or box.

This script continues beyond that step by adding:

zone size control,
distance filtering,
overlap management,
touch-based reinforcement,
optional retest-confirmed flips,
flip counting,
age-aware removal,
spatial eviction when the zone pool becomes crowded,
and visibility ranking so only the strongest nearby zones are shown.

That combination is the real distinguishing feature of the script.

It is not just a fractal marker. It is a fractal-based zone management engine.

Was this script really necessary?

In the strictest sense, the underlying market idea is not new. Fractal pivots, support, resistance, and role reversal are all established concepts.

So if the question is whether this script introduces a brand-new trading theory, the honest answer is no.

But that is not the reason it exists.

The reason it exists is that there is practical value in taking a familiar concept and implementing it in a cleaner, more selective, and more manageable way. A trader who already uses fractal structure may not need another script that simply draws more levels. What may still be useful is a script that helps reduce clutter, maintain zone quality, and keep attention on the strongest nearby structure.

That is the point of this indicator.

So the honest answer is:

it was not necessary as a new theory,
but it can be useful as a more organized implementation of fractal-based support and resistance.

That is the real justification for the script.

Inputs and behavior

The script includes a small set of controls that shape how selective or lightweight the engine becomes.

Strategy changes how strict the filtering logic is. Conservative settings keep fewer zones and require stricter behavior. Aggressive settings allow more zones and looser filtering.

Performance controls how many zones can be tracked internally. Lighter modes reduce tracking load, while fuller modes allow broader detection.

Top Resistance Zones, Top Support Zones, and Top S/R Flip Zones limit how many ranked zones are actually shown.

Pivot Left Bars and Pivot Right Bars control fractal confirmation.

Max Zone Height (ATR) caps zone height.

Merge Sensitivity changes how aggressively nearby zones are combined.

Max Age controls the base lifespan of zones before age pruning removes them.

Require Retest for Flip changes whether role reversal happens immediately after a qualified break or waits for a retest.

Show Developing Zones enables early provisional zones before full confirmation. Because these are not fully confirmed yet, they may disappear.

Left Extension, Box Length, labels, colors, and the optional info panel control the visual presentation.

Alerts and chart workflow

The script provides alerts for:

new resistance zones,
new support zones,
S/R flips,
and zone breaks.

A practical workflow is to use the indicator to monitor the strongest nearby structural zones, then combine those zones with your own trend analysis, execution criteria, risk plan, or broader market context.

Important notes

This is a structural analysis tool. It does not predict price, guarantee reversals, or guarantee trade outcomes.

Confirmed fractal pivots appear only after the required right-side confirmation bars exist, so confirmed zones naturally appear with that built-in confirmation delay. If developing zones are enabled, the script may show temporary structure earlier, but those developing zones can disappear if price invalidates them before full confirmation.

Because of that, this indicator is best used as a framework for organizing price structure rather than as a standalone trade system.
Informacje o Wersji
This update changes the indicator to process calculations only on confirmed (closed) bars.

The main goal of this revision is to remove the previous intrabar instability where zones or events could appear, disappear, or change while a bar was still forming. With this version, zone creation, touch detection, break detection, S/R flip handling, and visibility selection are all based on confirmed bar data only.

Changes in this version

1) Confirmed bar processing
Zone creation, touch detection, break detection, and S/R flip logic now execute only after bar close. In the previous version, these calculations could react during intrabar price movement, which allowed temporary changes before confirmation.

2) Reference price system
All price-dependent calculations now use confirmed values from the previous bar:

close[1] instead of close
high[1] instead of high
low[1] instead of low
ta.atr(14)[1] instead of ta.atr(14)

This keeps zone ranking, colors, and visibility from changing while the current bar is still forming.

3) Visibility selection
The logic that determines which zones are displayed was previously handled in barstate.islast, which could cause visible instability on live bars. This logic now runs on confirmed bars for more stable rendering.

4) Alert flag handling
Alert boolean variables now reset at the start of each confirmed bar, which helps prevent unintended intrabar alert behavior during fast price movement.

Removed feature

The Show Developing Zones option has been removed.

That feature displayed provisional zones before full pivot confirmation. By design, those zones could appear and disappear as new bars formed. Since this version is focused on confirmed-bar behavior only, that feature was removed.

If you want faster zone detection, reduce the Pivot Right Bars setting to 1.

Signal delay

Because the script now relies on confirmed data only, all signals have a minimum delay of 1 bar.

The total delay from pivot formation to zone appearance is:

Pivot Right Bars + 1 bar

With the default setting of Pivot Right Bars = 2, zones appear 3 bars after the actual pivot high or low forms.

This delay is expected and is part of using confirmed data instead of intrabar updates.

Verification

To check the new confirmed-bar behavior:

Add the indicator to a chart
Wait for new zones to form during live market activity
Refresh the browser
Compare the zones after reload

If you notice a case where zones move or disappear unexpectedly after refresh, please report it in the comments with the symbol and timeframe.

Settings

General

Strategy: Controls zone filtering sensitivity
Performance: Controls internal zone pool size
Top Resistance Zones: Maximum number of resistance zones to display
Top Support Zones: Maximum number of support zones to display
Top S/R Flip Zones: Maximum number of flip zones to display
Show Labels: Toggle zone labels on/off
Show Info Panel: Toggle statistics panel on/off

Advanced

Pivot Left Bars: Left lookback period for fractal detection
Pivot Right Bars: Right confirmation period for fractal detection
Max Zone Height (ATR): Maximum zone height as ATR multiple
Merge Sensitivity: Controls how aggressively nearby zones merge
Max Age (bars): Maximum zone lifespan before automatic removal
Require Retest for Flip: When enabled, S/R flip requires break plus retest
Left Extension: Extend zone boxes to the left
Box Length: Fixed box length in bars (0 = extend right indefinitely)

Style

Label Size: Size of zone labels
H-Align: Horizontal alignment of labels
Resistance: Color for resistance zones
Support: Color for support zones
S/R Flip: Color for flip zones
Label Color: Text color for labels
Alerts

Four alert conditions are available:

New Resistance: Triggers when a new resistance zone is confirmed
New Support: Triggers when a new support zone is confirmed
S/R Flip: Triggers when a zone changes polarity
Zone Break: Triggers when price breaks through a zone

All alerts now fire on confirmed bar close only.

Zone behavior

Zones are ranked using a scoring model that considers:

number of touches,
number of flips,
distance from current price,
and age.

Only the highest-scoring zones, up to the user-defined display limits, are shown on the chart. Lower-ranked zones may remain tracked internally and can become visible later if stronger zones are removed.

Zones with more interaction history can also remain active longer than weaker zones, depending on the configured age logic.

Known limitations
Minimum 1-bar delay on all signals
Historical zone placement may differ slightly from earlier versions because the calculation model has changed
Very fast timeframes, especially with aggressive settings, may still produce a high number of zones
Feedback

If you encounter unexpected behavior, please provide:

symbol and timeframe,
description of the issue,
and a screenshot if possible.
Informacje o Wersji
Fractal S/R v7 Core is an open-source support and resistance zone indicator built around confirmed fractal pivots.

The script detects potential resistance zones from confirmed pivot highs and potential support zones from confirmed pivot lows. Zone height is normalized with ATR so very large candles do not create oversized areas. Nearby overlapping zones can be merged, older zones are pruned over time, and the script keeps a limited pool of zones to maintain a cleaner chart. The visible zones are then selected by score, using touch count, age, and distance from the current confirmed reference price. These mechanics are present in the code through confirmed pivot detection, ATR-based sizing, merge sensitivity, aging rules, zone pool control, and visible zone scoring/selection.

This script is designed as a chart-structure tool, not as a standalone trading system. It does not attempt to predict future price movement, and support/resistance zones should be interpreted in context with market structure, volatility, and the user’s own trade plan. Signals are not guaranteed, and zones can lose relevance as market conditions change. Stating limits like these helps keep the description aligned with TradingView’s requirement to avoid unrealistic claims or misleading performance language.

How it works:

Uses confirmed fractal pivots to create candidate zones.
Caps zone height with ATR to keep zones proportional to volatility.
Merges nearby or overlapping zones when appropriate.
Tracks touch count to help rank zone relevance.
Removes older zones progressively.
Displays the strongest resistance zones above price and the strongest support zones below price.

Main inputs:

Number of visible resistance and support zones
Pivot left / right settings
Max zone height in ATR units
Merge sensitivity
Max age in bars
Zone pool size
Box extension and label settings

Notes:

Zones appear only after pivot confirmation, so they are not intended to mark turning points in advance.
This is the simplified core version focused on zone detection and visualization.
The script is open-source so users can inspect, modify, and extend the logic for their own workflow. Open-source publication and clear explanation are consistent with TradingView’s publishing expectations for public scripts.
Informacje o Wersji
Update Notes — Version 3

This update improves Fractal S/R Zones with a cleaner zone engine, better support/resistance role handling, and expanded alert conditions.

What’s New:

* Added Support/Resistance flip logic. When a resistance zone is broken, it can become support. When a support zone is broken, it can become resistance.
* Added Break Confirmation settings with Close or Wick confirmation.
* Added an ATR-based Break Buffer to reduce weak or premature zone breaks.
* Added Resistance Test and Support Test alerts.
* Added Resistance → Support and Support → Resistance flip alerts.
* Added a Sensitivity profile with Low, Normal, High, and Ultra modes.
* Added ATR-scaled merge and spacing logic so zone behavior adapts better across symbols and timeframes.
* Added volume weighting to newly created zones.
* Added flipped-zone styling using dashed borders.
* Added mixed-zone coloring when price is currently inside a zone.

Improvements:

* Zone scoring has been improved with touches, recency, volume weight, flipped status, and ATR-based proximity.
* Zone memory management has been improved so strong but distant zones can remain available until price returns to them.
* Zone merging is now role-aware, so support zones merge with support and resistance zones merge with resistance.
* Touch handling is now based on confirmed rejection behavior.
* Aging is now based on the last zone activity instead of only the original creation bar.
* Rendering has been simplified and now runs on the last bar for a cleaner chart.
* Label handling has been improved with a separate label store.
* Default drawing limits were reduced for a lighter and cleaner chart experience.

Important Note:
Because this update changes zone scoring, merging, break handling, role flipping, and rendering behavior, some zones may appear differently compared to the previous version. This is expected.

This indicator is designed for educational and analytical use. It does not provide financial advice, trade entries, stop-loss levels, take-profit levels, or performance guarantees.

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.