OPEN-SOURCE SCRIPT

Fractal Support & Resistance Zones invincible]

4 528
Fractal Support & Resistance Zones [invincible3]

Fractal Support & Resistance Zones [invincible3] is an advanced market-structure and price-reaction framework designed to identify, evaluate, and dynamically manage support and resistance zones derived from confirmed fractal pivots.

Unlike traditional support and resistance indicators that simply draw horizontal levels at swing highs and lows, this indicator treats every zone as a dynamic market structure object. Each zone develops through its own lifecycle based on price interaction, independent retests, reaction strength, penetration, estimated buying and selling activity, structural confirmation, trend alignment, and eventual support/resistance role reversal.

The objective is not simply to show where price previously turned.

The objective is to evaluate which zones are still technically relevant, which have gained confirmation, which are weakening, and which may provide better structural trade locations.

---------------------------------------------------------------------------------------------

Fractal-Based Zone Detection

The indicator identifies two independent classes of fractal pivots:

Weak Fractals

Shorter-length pivots designed to capture local price reactions and minor structural turning points.

Major Fractals

Higher-strength pivots based on a larger fractal window. These represent more significant swing highs and swing lows and receive greater importance within the zone-quality model.

Fractal support zones are created from confirmed pivot lows, while fractal resistance zones are generated from confirmed pivot highs.

The detection timeframe can be independently selected, allowing zones from a higher timeframe to be displayed on a lower-timeframe chart.

Higher-timeframe fractal data is requested with lookahead disabled to prevent future data from being intentionally introduced into the pivot calculation.

---------------------------------------------------------------------------------------------

Dynamic Support and Resistance Zones

The indicator creates price zones rather than single horizontal lines.

Markets rarely react from one exact price. Orders, liquidity, and previous positioning are often distributed across a price range. The zone model therefore attempts to represent the broader reaction area surrounding a fractal pivot.

Three zone-width methods are available:

ATR

Zone width is calculated from Average True Range and automatically adapts to market volatility.

Pivot Candle

The structure of the original fractal candle is used to determine the zone width.

Hybrid Candle + ATR

Combines pivot-candle structure with an ATR-based volatility limit.

The hybrid method is designed to prevent unusually large pivot candles from creating excessively wide support or resistance areas.

A minimum tick-based width can also be configured for instruments with very small price movements.

---------------------------------------------------------------------------------------------

Fractal Zone Clustering

Markets frequently produce several nearby fractal pivots around the same price area.

Drawing every pivot independently can create overlapping boxes and unnecessary chart congestion.

The indicator therefore includes a fractal clustering engine.

Nearby same-side fractals may be merged into a common structural zone when:

* They are within the configured ATR merge distance.
* The resulting merged zone does not exceed the maximum permitted ATR width.
* The maximum cluster count has not been exceeded.
* Fresh major zones are not being merged into previously tested or damaged zones when protection is enabled.

The cluster count becomes one component of the zone-quality model.

A cluster does not automatically mean a zone is strong. It simply indicates that multiple independent fractal structures developed around a similar price area.

---------------------------------------------------------------------------------------------
Independent Retest Detection

A major feature of the indicator is the distinction between bars inside a zone and independent zone retests.

If price remains inside a support or resistance area for several candles, those candles are not counted as multiple tests.

A new test is counted only after price:

1. Interacts with the zone.
2. Moves sufficiently away from the zone.
3. Travels the configured ATR reset distance.
4. Returns to the zone again.

This creates a more realistic retest model and avoids artificially increasing the test count during sideways congestion.

The label displays the number of independent tests recorded for each selected zone.

---------------------------------------------------------------------------------------------

ATR-Based Reaction Measurement

After an independent zone retest, the indicator measures how strongly price reacts away from the zone.

Reaction strength is normalized using ATR.

For a support zone, the engine measures upward movement from the reaction anchor.

For a resistance zone, the engine measures downward movement from the reaction anchor.

The strongest reaction generated by the zone is stored as its **Best Reaction ATR**.

Two configurable reaction thresholds are used:

Verified Reaction

The zone has produced the minimum ATR reaction required for technical validation.

Proven Reaction

The zone has generated a stronger ATR reaction and has also accumulated sufficient independent testing.

This prevents a zone from receiving a high structural status simply because price briefly touched it.

The market must demonstrate an actual directional response.

---------------------------------------------------------------------------------------------

Dynamic Zone Status System

Every zone is continuously classified according to its current structural condition.

FRESH

A newly created major zone that has not yet received an independent retest.

Fresh zones may represent relatively untouched structural areas.

WEAK

A zone originating from the shorter weak-fractal detection model.

Weak zones can still produce valid reactions but receive a lower fractal-grade contribution in the quality model.

VERIFIED

A zone that has been tested and remains structurally active.

Reaction behaviour and zone validation contribute dynamically to its score.

PROVEN

A zone that has accumulated multiple independent tests and generated a reaction exceeding the configured Proven Reaction ATR threshold.

Proven zones represent areas with demonstrated historical reaction behaviour.

DAMAGED

Price has penetrated a configurable percentage of the zone.

A damaged zone has not necessarily broken, but deeper penetration reduces its quality score.

BROKEN

Price has invalidated the zone according to the selected break-confirmation method.

Break confirmation can use either:

* Close Beyond Zone
* Full Candle Beyond Zone

Broken zones may optionally remain visible for historical analysis.

FLIPPED SUPPORT / FLIPPED RESISTANCE

A previously broken zone has confirmed a structural role reversal.

Previous support may become resistance.

Previous resistance may become support.

The indicator does not immediately flip a zone when price crosses it. A separate role-reversal confirmation process is required.

---------------------------------------------------------------------------------------------

Zone Damage and Penetration Tracking

Zone quality is not binary.

A support or resistance area may gradually weaken before it completely breaks.

The indicator continuously measures the maximum percentage of zone penetration.

For support, penetration is measured downward through the support area.

For resistance, penetration is measured upward through the resistance area.

When penetration exceeds the configured damage threshold, the zone is classified as **DAMAGED

Damage also applies a progressive penalty to the quality score.

This means a deeply penetrated zone may remain technically valid while receiving a lower structural ranking.

---------------------------------------------------------------------------------------------

Support and Resistance Role Reversal

The indicator contains a dedicated zone-flip engine.

After a support or resistance zone breaks, the engine monitors whether price moves sufficiently beyond the former zone.

The broken zone must first establish separation from price using a configurable ATR distance.

Price must then return to the previous structural area.

Depending on the selected confirmation mode, the indicator can require:

Zone Reclaim Only

The opposite-side retest itself is sufficient.

Close Away

Price must close a configurable ATR distance away from the zone.

Rejection or Engulfing

The retest can be confirmed through rejection behaviour, an engulfing candle, or a sufficiently strong close away from the zone.

Once confirmed:

* Broken support can become resistance.
* Broken resistance can become support.

The zone is then reset into a new lifecycle as a flipped structural area.

---------------------------------------------------------------------------------------------

Estimated Buy and Sell Activity

The indicator includes an estimated directional volume model.

Because standard TradingView volume does not directly provide true executed bid and ask volume for every market, buying and selling activity is estimated from candle position within the candle range.

A close nearer the candle high allocates a greater portion of volume to estimated buying activity.

A close nearer the candle low allocates a greater portion of volume to estimated selling activity.

The model can use:

* Pivot volume only.
* Pivot volume plus independent retest activity.

Selected zone labels display estimated activity as:

B 64% | S 36%

This should be interpreted as an estimated directional participation model rather than true exchange-level order-flow delta.

---------------------------------------------------------------------------------------------

Multi-Factor Zone Quality Model

Every zone receives a dynamic quality score from 0 to 10.

The score is not based on a single condition.

The model combines several structural factors.

Fractal Grade

Major fractals receive a stronger contribution than weak fractals.

Rejection Wick

The pivot candle's rejection wick is normalized against ATR.

Larger relative rejection can increase the origin score.

Independent Retests

The model evaluates how many genuinely independent zone tests have occurred.

Importantly, unlimited retests do not continuously improve quality.

Excessive testing can weaken a zone.

Reaction Strength

The strongest measured ATR reaction contributes to zone validation.

Estimated Volume Confirmation

Pivot volume participation and directional estimated activity contribute to the score.

Fractal Cluster

Multiple nearby fractals can increase structural confidence.

Freshness

Newer zones receive a greater freshness contribution.

As a zone ages, this component gradually decreases.

The weight of every major quality component can be adjusted by the user.

---------------------------------------------------------------------------------------------

Origin Score and Validation Score

Internally, the quality engine separates zone evaluation into two conceptual stages.

Origin Quality

Evaluates how the zone was created.

This includes:

* Fractal grade.
* Pivot rejection wick.
* Pivot volume participation.
* Fractal clustering.
* Zone freshness.

Validation Quality

Evaluates what price did after the zone was created.

This includes:

* Independent retests.
* Reaction strength.
* Directional estimated activity.

Fresh zones are influenced more heavily by origin quality.

As price begins interacting with a zone, validation behaviour receives greater influence.

This allows the quality score to evolve with market behaviour rather than remaining permanently fixed at zone creation.

---------------------------------------------------------------------------------------------

Retest Exhaustion Penalty

A common assumption is that more support or resistance tests always make a zone stronger.

This indicator does not use that assumption.

Repeated interaction may gradually consume resting liquidity around a price area.

After the configured number of retests, the indicator begins applying an excess retest penalty.

The penalty increases with each additional independent test.

As a result, a heavily tested zone may receive a lower quality score even if it has not formally broken.

---------------------------------------------------------------------------------------------

Congestion Penalty

Price remaining inside a zone for an extended period may indicate balance, absorption, or structural deterioration.

The indicator tracks consecutive bars interacting with each zone.

After the configured congestion threshold, a progressive quality penalty is applied.

This helps distinguish a clean rejection from prolonged price acceptance inside the area.

---------------------------------------------------------------------------------------------

Trend Regime Alignment

An optional EMA-based trend regime is included in the quality model.

Support zones located in an unfavourable bearish regime can receive a counter-trend penalty.

Resistance zones located in an unfavourable bullish regime can also receive a penalty.

The trend filter does not automatically delete zones.

Instead, it modifies their relative quality.

This allows historically valid support and resistance areas to remain visible while acknowledging the current directional regime.

---------------------------------------------------------------------------------------------

Market Structure Break Detection

The indicator includes an independent Market Structure Break, or **MSB**, engine.

Confirmed swing highs and swing lows are detected using a configurable pivot length.

A bullish MSB occurs when price closes above the latest eligible structural high with sufficient momentum confirmation.

A bearish MSB occurs when price closes below the latest eligible structural low with sufficient negative momentum confirmation.

Momentum is normalized using a Z-score calculated from recent price changes.

This reduces the number of minor structural crossings classified as meaningful breaks.

Each structural pivot can generate only one MSB event, preventing repeated labels from appearing after the same swing has already been broken.

---------------------------------------------------------------------------------------------

Zone-to-Structure Confirmation

Market Structure Breaks can also validate previously tested zones.

When a bullish MSB occurs, the indicator searches for a recently touched support zone.

When a bearish MSB occurs, it searches for a recently touched resistance zone.

The most recent eligible zone can receive structural confirmation.

A configurable quality bonus is then applied.

This creates a basic structural sequence:

Zone interaction → Price reaction → Market Structure Break

The intention is to distinguish zones that merely produced a temporary bounce from zones followed by a measurable structural shift.

---------------------------------------------------------------------------------------------

Premium and Discount Trade Location

The indicator uses the latest structural swing high and swing low to estimate the current swing midpoint.

The midpoint represents the 50% equilibrium level of the structural range.

When Premium/Discount grading is enabled:

* Support zones are favoured when positioned in the discount portion of the swing.
* Resistance zones are favoured when positioned in the premium portion of the swing.

This condition contributes to the displayed Trade Grade.

It does not remove zones from the chart.

---------------------------------------------------------------------------------------------
Trade Grade System

Selected zones receive a simplified structural trade grade.

Grade A+

Reserved for high-quality zones with strong alignment between:

* Zone quality.
* Trend regime.
* Premium/discount location.
* Low structural damage.
* Limited retest exhaustion.

Grade A

Strong-quality zones with favourable trend alignment and low damage.

Grade B

Moderate-to-strong structural zones that are not classified as weak fractals.

Grade C

Lower-quality but still technically visible zones.

Grade D

Zones with poor overall structural quality.

The Trade Grade is a contextual ranking system.

It is not an automatic buy or sell signal.

---------------------------------------------------------------------------------------------
Star-Based Quality Display

To make the detailed labels easier to read, the numerical quality model is represented using stars.

★★★★★ = Quality 8.0 or higher

★★★★ = Quality 6.0 to 7.99

★★★ = Quality 4.0 to 5.99

★★ = Quality 2.0 to 3.99

★ = Quality below 2.0

The stars provide a quick visual representation of the underlying 0–10 quality score.

---------------------------------------------------------------------------------------------

Compact Detailed Labels

Selected zones can display compact one-line labels such as:

VERIFIED SUP | B 64% | S 36% | ★★★★ | Tests: 2 | Grade A

The label contains:

* Current zone status.
* Support or resistance classification.
* Estimated buying activity.
* Estimated selling activity.
* Quality stars.
* Independent retest count.
* Structural Trade Grade.

Because displaying a detailed label on every zone can create significant chart congestion, two label modes are available.

Nearest + Strongest

Prioritizes the nearest support, nearest resistance, and the highest-quality remaining zones.

All Visible Zones

Displays labels for every currently visible zone.

The maximum number of detailed labels can also be controlled.

---------------------------------------------------------------------------------------------

Nearest Zone Highlighting

The indicator continuously identifies:

* The nearest active support below price.
* The nearest active resistance above price.

These zones can receive stronger border highlighting.

This makes the most immediately relevant structural areas easier to identify without removing historical zones from the chart.

---------------------------------------------------------------------------------------------

Structural Equilibrium Zone

The latest confirmed structural swing high and swing low are used to calculate a 50% equilibrium area.

The indicator plots:

* Swing origin.
* Swing destination.
* 50% midpoint.
* Configurable equilibrium zone thickness.

Before price interacts with the equilibrium area, the zone is displayed as the current structural midpoint.

After price touches the area, the indicator changes its state to:

Equilibrium touched · wait for structure

This is intended to remind the trader that equilibrium interaction alone is not necessarily directional confirmation.

Additional market structure may be required.

---------------------------------------------------------------------------------------------

Alert Conditions

The indicator provides alert conditions for important zone and market-structure events:

* New fractal support zone.
* New fractal resistance zone.
* Independent zone retest.
* Zone verified by ATR reaction.
* Zone reaching Proven status.
* Zone becoming Damaged.
* Zone break.
* Support/resistance role reversal.
* Bullish Market Structure Break.
* Bearish Market Structure Break.

These alerts can be used to monitor structural changes without continuously watching the chart.

---------------------------------------------------------------------------------------------

Suggested Interpretation

This indicator is designed as a market context and structural analysis tool.

A possible analytical workflow is:

1. Identify the nearest active support and resistance.
2. Review the zone's current status.
3. Check estimated buy/sell activity.
4. Evaluate the quality stars.
5. Review the independent test count.
6. Check whether the zone is fresh, validated, damaged, or exhausted.
7. Evaluate trend alignment.
8. Check premium or discount location.
9. Observe whether price produces a structural break after the zone reaction.
10. Use the Trade Grade as an additional contextual ranking.

No single factor should be interpreted independently.

A five-star zone can still break.

A damaged zone can still generate a reaction.

A weak fractal can still become structurally relevant.

The purpose of the model is to organize multiple price-action variables into a consistent framework.

---------------------------------------------------------------------------------------------

Important Volume Note

The Buy and Sell percentages displayed by this indicator are estimated directional volume statistics.

They are calculated by allocating candle volume according to the closing position within the candle's high-low range.

They do not represent true bid/ask volume, footprint delta, or exchange-level aggressive buying and selling.

The values should therefore be used as a relative activity estimate only.

---------------------------------------------------------------------------------------------

Non-Repainting Considerations

Fractal pivots require confirmation bars.

A zone is created only after the corresponding pivot has been confirmed by the selected fractal length.

Higher-timeframe fractal calculations use `lookahead_off`.

Therefore, historical zones should be interpreted from the point at which the fractal became technically confirmed rather than assuming the pivot was known at the exact swing candle in real time.

Market Structure Break conditions are also evaluated using confirmed price and momentum conditions.

---------------------------------------------------------------------------------------------

Final Note

Fractal Support & Resistance Zones [invincible3] is designed for traders who prefer **dynamic structural zones instead of static support and resistance lines**.

The indicator combines fractal structure, volatility-normalized zone construction, independent retests, reaction measurement, damage analysis, estimated directional activity, structural breaks, trend regime, premium/discount location, and role reversal into a unified zone lifecycle model.

It is intended to help answer three practical questions:

Where is the important price structure?

How has price behaved around that structure?

Is the zone gaining validation, remaining fresh, or gradually losing structural quality?

This indicator is intended for technical analysis and research purposes only. It does not constitute financial advice. Traders should independently evaluate market conditions and apply appropriate risk management.

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

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