OPEN-SOURCE SCRIPT

Apex Pivot & S/R Dynamics [Pineify]

622
Apex Pivot & S/R Dynamics

This indicator maps structural support and resistance directly from confirmed pivot highs and lows, then tracks each level in real time until price decisively closes through it. Rather than drawing static zones at fixed intervals, every line is anchored to an actual swing point and extended bar by bar — the moment a close-based breach occurs, the line is deleted and a breakout label appears. The result is a chart that reflects only the levels that are still relevant right now.

Key Features

  • Pivot-confirmed S/R lines drawn at the exact bar where a swing high or low was established
  • Close-based breakout detection with a one-bar confirmation filter — no reaction to wicks alone
  • Automatic line removal on breach, keeping the chart free of invalidated levels
  • Configurable cap on active lines per side; oldest unbroken levels drop off when the limit is hit
  • Separate color controls for resistance, support, bullish breakout labels, and bearish breakout labels


How It Works

Pine's built-in ta.pivothigh() and ta.pivotlow() functions require price to form a local extreme confirmed by length bars on both sides. A pivot confirmed with length=15 means the indicator "sees" it 15 bars after it forms — and draws the line aligned back to that original swing bar. This lag is inherent to pivot detection and trades off responsiveness for confirmation quality.

Each confirmed pivot spawns a dashed horizontal line stored in a typed array alongside its exact price. Every subsequent bar, the loop iterates through active lines and extends them to the current bar. When a close-above-resistance or close-below-support transition occurs (previous close on the wrong side, current close on the right side), the breakout condition fires: the line is deleted from the array, an annotated label is placed, and the level is gone from the chart permanently.

  1. Bars accumulate until a swing extreme is confirmed on both sides
  2. A dashed line is created at the pivot price, extending right indefinitely
  3. Each bar, the loop checks whether price has closed through each level
  4. On breach: label placed, line deleted, level removed from active tracking
  5. If unbroken levels exceed the configured cap, the oldest is silently removed


How the Components Work Together

The pivot detection sets the quality bar for which prices become levels — only price extremes that the market has already tested and respected on both sides qualify. The one-bar close confirmation then filters out wicks that pierce a level intrabar but don't follow through: a single candle that closes back inside the range doesn't trigger a breakout. Together, these two filters mean the breakout label fires on the first candle that suggests actual intent to move away from the level, not just noise around it.

The array-based memory management is what separates this from simpler implementations that draw lines and forget them. Because each line object is tracked with its price level, the indicator can cleanly unwind invalidated structure rather than letting stale lines accumulate across months of history.

Trading Ideas and Insights

  • On a retest setup: watch for price to pull back to a freshly broken resistance level (now acting as support) without triggering a new bearish breakout label — that silence is the confirmation
  • When multiple resistance lines cluster within a few ticks of each other, the zone represents confluent supply; a breakout label through that cluster carries more weight than a breach of an isolated swing
  • Use the breakout label count per session as a rough measure of trend strength — trending days tend to fire several same-direction labels in sequence, while ranging days flip back and forth
  • On higher timeframes (daily, weekly), the lines mark major structural zones; consider using a tighter lookback (8–10) on intraday charts where swing structure is denser


Past behavior at these levels does not guarantee future outcomes. S/R analysis works best when combined with volume, momentum, or broader context rather than used in isolation.

Unique Aspects

  • Lines are anchored to their originating pivot bar visually — the small triangle marker shows exactly which candle created each level, so you can assess the quality of the original swing without scrolling back
  • Close-based breakout confirmation with a prior-bar check is more conservative than most pivot S/R scripts, which often fire on any penetration regardless of close location
  • The self-cleaning design — lines disappear when breached and oldest lines drop when the cap is hit — makes the chart readable across all timeframes without manual cleanup


How to Use

  1. Add to any chart; the indicator overlays directly on price with no separate pane
  2. Adjust "Pivot Lookback" to match your timeframe — higher values (20–30) on daily charts identify major structure; lower values (5–10) on intraday charts capture faster swings
  3. Red dashed lines are active resistance levels; green dashed lines are active support levels
  4. A blue "B" label above a bar signals a bullish breakout through resistance; an orange "B" below signals a bearish breakdown through support
  5. If the chart becomes crowded, lower "Max Active Lines" to keep only the most recent unbroken levels visible


Customization

  • Pivot Lookback (default: 15) — Controls how many bars on each side must be lower/higher to confirm a pivot. Increasing this confirms stronger, less frequent levels; decreasing it produces more levels with earlier detection but more sensitivity to minor swings.
  • Highlight Breakouts (default: on) — Toggles the breakout labels. Turn off if you only want the S/R lines without annotation.
  • Max Active Lines (default: 15) — Caps the number of lines per side. On instruments with very dense swing structure or long histories, reducing this to 8–10 keeps the chart uncluttered.
  • Line and Label Colors — Four separate color inputs for resistance lines, support lines, bullish breakout labels, and bearish breakout labels. Adjust to match your chart theme.


Conclusion

Apex Pivot & S/R Dynamics automates the manual process of marking swing highs and lows, extending them forward, and cleaning them up when they are no longer valid. The close-based breakout filter and automatic array management mean the chart reflects current market structure rather than accumulated history. Traders focused on price action and structural levels — particularly those who trade retests and breakout continuations — will find this a practical alternative to manually drawn S/R zones.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.