OPEN-SOURCE SCRIPT
Обновлено S/R Zone Flip Tracker v9.5 - SAMMY

S/R Zone Flip Tracker
WHAT IT DOES
This indicator detects support and resistance zones from confirmed price pivots, then tracks when price breaks through a zone and "flips" its role - broken resistance becomes support, broken support becomes resistance. Flipped zones are recolored and highlighted for a configurable number of bars, and flip events fire markers and alerts. A ladder table lists the nearest zones above and below current price, sorted by distance, so you can read the immediate S/R structure at a glance without scanning the chart.
HOW IT WORKS
1. Zone creation: Swing highs and lows are detected with ta.pivothigh / ta.pivotlow. Each confirmed pivot creates a zone centered on the pivot price. Zone half-width is either a multiple of ATR (adaptive to volatility) or a fixed dollar amount, selectable in settings.
2. Zone maintenance: Nearby zones are merged when their midpoints fall within an ATR-based merge threshold. New pivots that land inside an existing zone's dedup radius are discarded instead of stacking duplicates. Zones farther from price than a distance cap (the larger of an ATR window and a percent-of-price window) are pruned, and if more zones remain than the per-mode maximum, the farthest ones are evicted. This keeps only the structurally relevant levels on the chart.
3. Flip detection: On each confirmed bar close, every zone is tested against the break method you select. "Close" requires the candle to close beyond the zone edge plus an ATR-based confirmation buffer. "Wick" allows the high/low to trigger the break. When a zone is broken upward it is reclassified as support; broken downward it becomes resistance. The flip bar is recorded so recently flipped zones render in a stronger highlight color and are tagged "S Flipped" / "R Flipped" until the highlight age expires.
4. Flip throttling: A minimum-bars-between-flips setting suppresses repeated flip signals on the same side within a short window, reducing noise in choppy conditions.
5. Trading modes: Scalping, Intraday, Swing, and Position modes each carry their own independent parameter set (pivot length, zone width, confirmation buffer, flip throttle, zone count, distance caps). "Auto" selects the mode from the chart timeframe. "Manual" exposes a fully custom set. This lets one script behave sensibly from 1-minute charts to weekly charts without retuning on every timeframe change.
6. EMA cloud: An optional 9/21 EMA cloud (lengths configurable) provides directional context behind the zones. Green fill when fast is above slow, red when below.
NON-REPAINTING DESIGN
All flip state changes are gated on barstate.isconfirmed, so flips, markers, and alerts only occur on closed bars and do not change after the fact. The optional higher-timeframe confirmation uses request.security with a confirmed-bar offset so the higher-timeframe value never previews an unclosed HTF bar: on closed chart bars it reads the current HTF value, and on the developing bar it reads the last closed HTF value. Pivots by nature confirm only after the right-side lookback completes, so zones appear a fixed number of bars after the actual swing point - this is inherent to pivot detection, not repainting.
HOW TO USE IT
- Leave Trading Mode on Auto to let the script pick parameters from your chart timeframe, or select a mode explicitly to tune it.
- Watch the ladder table for the three nearest resistance zones above price and three nearest support zones below, with price and percent distance for each. An asterisk marks recently flipped zones.
- "Flip Up" markers print when resistance is confirmed broken and reclassified as support; "Flip Dn" marks the opposite. These are commonly read as breakout-and-retest context: a fresh flip zone is a candidate area for price to retest from the other side.
- Enable MTF Close Confirmation to require the break to hold on a higher timeframe before a flip registers, which filters out breaks that only exist on the chart timeframe.
- Three alerts are available: flip to support, flip to resistance, and any flip.
SETTINGS SUMMARY
- Per-mode: pivot left/right length, zone width ATR multiple, confirmation buffer, minimum bars between flips, max zones shown, distance caps (ATR multiple and percent).
- General: ATR length, break method (Close or Wick), dedup and merge thresholds, zone width mode (ATR or Fixed $), flip highlight age.
- Visual: zone colors for support, resistance, and recently flipped states; EMA cloud toggle and lengths; ladder table position and font size.
LIMITATIONS
- Zones confirm pivot-right bars after the swing point (inherent lag of pivot detection).
- Flip markers older than the Flip Label Lookback are not redrawn on chart reload; live alerts are unaffected.
- Requires roughly pivot length plus ATR length bars of history before the first zones appear.
- This is an analysis tool, not a trading system. It does not predict price and generates no buy/sell recommendations.
WHAT IT DOES
This indicator detects support and resistance zones from confirmed price pivots, then tracks when price breaks through a zone and "flips" its role - broken resistance becomes support, broken support becomes resistance. Flipped zones are recolored and highlighted for a configurable number of bars, and flip events fire markers and alerts. A ladder table lists the nearest zones above and below current price, sorted by distance, so you can read the immediate S/R structure at a glance without scanning the chart.
HOW IT WORKS
1. Zone creation: Swing highs and lows are detected with ta.pivothigh / ta.pivotlow. Each confirmed pivot creates a zone centered on the pivot price. Zone half-width is either a multiple of ATR (adaptive to volatility) or a fixed dollar amount, selectable in settings.
2. Zone maintenance: Nearby zones are merged when their midpoints fall within an ATR-based merge threshold. New pivots that land inside an existing zone's dedup radius are discarded instead of stacking duplicates. Zones farther from price than a distance cap (the larger of an ATR window and a percent-of-price window) are pruned, and if more zones remain than the per-mode maximum, the farthest ones are evicted. This keeps only the structurally relevant levels on the chart.
3. Flip detection: On each confirmed bar close, every zone is tested against the break method you select. "Close" requires the candle to close beyond the zone edge plus an ATR-based confirmation buffer. "Wick" allows the high/low to trigger the break. When a zone is broken upward it is reclassified as support; broken downward it becomes resistance. The flip bar is recorded so recently flipped zones render in a stronger highlight color and are tagged "S Flipped" / "R Flipped" until the highlight age expires.
4. Flip throttling: A minimum-bars-between-flips setting suppresses repeated flip signals on the same side within a short window, reducing noise in choppy conditions.
5. Trading modes: Scalping, Intraday, Swing, and Position modes each carry their own independent parameter set (pivot length, zone width, confirmation buffer, flip throttle, zone count, distance caps). "Auto" selects the mode from the chart timeframe. "Manual" exposes a fully custom set. This lets one script behave sensibly from 1-minute charts to weekly charts without retuning on every timeframe change.
6. EMA cloud: An optional 9/21 EMA cloud (lengths configurable) provides directional context behind the zones. Green fill when fast is above slow, red when below.
NON-REPAINTING DESIGN
All flip state changes are gated on barstate.isconfirmed, so flips, markers, and alerts only occur on closed bars and do not change after the fact. The optional higher-timeframe confirmation uses request.security with a confirmed-bar offset so the higher-timeframe value never previews an unclosed HTF bar: on closed chart bars it reads the current HTF value, and on the developing bar it reads the last closed HTF value. Pivots by nature confirm only after the right-side lookback completes, so zones appear a fixed number of bars after the actual swing point - this is inherent to pivot detection, not repainting.
HOW TO USE IT
- Leave Trading Mode on Auto to let the script pick parameters from your chart timeframe, or select a mode explicitly to tune it.
- Watch the ladder table for the three nearest resistance zones above price and three nearest support zones below, with price and percent distance for each. An asterisk marks recently flipped zones.
- "Flip Up" markers print when resistance is confirmed broken and reclassified as support; "Flip Dn" marks the opposite. These are commonly read as breakout-and-retest context: a fresh flip zone is a candidate area for price to retest from the other side.
- Enable MTF Close Confirmation to require the break to hold on a higher timeframe before a flip registers, which filters out breaks that only exist on the chart timeframe.
- Three alerts are available: flip to support, flip to resistance, and any flip.
SETTINGS SUMMARY
- Per-mode: pivot left/right length, zone width ATR multiple, confirmation buffer, minimum bars between flips, max zones shown, distance caps (ATR multiple and percent).
- General: ATR length, break method (Close or Wick), dedup and merge thresholds, zone width mode (ATR or Fixed $), flip highlight age.
- Visual: zone colors for support, resistance, and recently flipped states; EMA cloud toggle and lengths; ladder table position and font size.
LIMITATIONS
- Zones confirm pivot-right bars after the swing point (inherent lag of pivot detection).
- Flip markers older than the Flip Label Lookback are not redrawn on chart reload; live alerts are unaffected.
- Requires roughly pivot length plus ATR length bars of history before the first zones appear.
- This is an analysis tool, not a trading system. It does not predict price and generates no buy/sell recommendations.
Информация о релизе
v9.8 — Zone Pool Persistence + MTF Flip Fix- FIXED: Wrong-direction flips when MTF Confirmation was enabled. The higher-timeframe close previously REPLACED the chart-timeframe break price, so on lower chart timeframes the stale HTF value could flip zones to Resistance while price was rallying far above them. The HTF value is now a confirmation gate ANDed with the chart-timeframe break: MTF can delay a flip, but can never cause a flip in the wrong direction.
- NEW: Persistent zone pool. Zones far from price are now HIDDEN, not deleted. On strong trends, old levels survive off-screen and automatically reappear when price pulls back to them. Previously the pool was pruned destructively and trending charts permanently lost their zone history.
- CHANGED: Distance visibility now requires a zone to be inside BOTH the ATR window AND the percent window (tighter window binds). Previously either window alone kept a zone, which made one of the two inputs ineffective.
- CHANGED: Auto-mode buckets clarified — Daily now lands in Swing; Weekly and Monthly land in Position (relabeled "1W-1M").
- Flip detection now scans the full pool, so a hidden zone still flips correctly the moment price breaks through it.
- No new inputs; all existing settings, alerts, and visuals unchanged.
Информация о релизе
RELEASE NOTES (v9.10 update)v9.10 — Zone quality overhaul for higher timeframes
This update fixes zone starvation and wrong-type zones on daily and weekly charts, especially on volatile symbols.
Fixed:
Support and resistance zones near the same price were being merged into a single wrong-type zone. Merging is now type-aware — support never merges with resistance.
Very few zones appeared on daily charts of volatile symbols. Merge and dedup thresholds were based on live ATR, which enforced huge minimum spacing between levels. Both now use each zone's own stored width, so zone density is correct on every timeframe.
Volatility spikes (earnings, gaps) permanently collapsed the zone map. Merging now runs only when a new zone is created or a flip occurs, never on ordinary bars, so ATR expansion can no longer destroy existing levels.
A support pivot printing inside an existing resistance zone (the classic broken-level retest) was silently discarded. Dedup is now type-aware, so paired S/R structure at the same price forms correctly.
Selecting an MTF timeframe lower than the chart silently corrupted the confirmation gate. It now auto-bypasses with no effect on flips.
Improved:
Merged zones now span the union of both original zones and keep the most recent flip history, instead of being rewritten with the current bar's ATR width.
Overlapping opposite-type zones that flip to the same type after a break now consolidate into one zone automatically.
Note: if updating from a previous version, reset the indicator inputs to defaults (or re-add it) to pick up the new Dedup Multiplier default of 2.5.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.