OPEN-SOURCE SCRIPT

Swing Structure Bands [ChartPrime]

4 216
⯁ OVERVIEW
Swing Structure Bands is a structure-based trend and reaction indicator that builds adaptive price bands directly from swing highs and swing lows.
Instead of using fixed-length moving averages, the bands dynamically adjust their length based on how long price has been forming higher highs or lower lows, allowing the indicator to naturally align with real market structure.

istantanea
This makes the tool especially effective for identifying swing-based support and resistance, trend continuation zones, and exhaustion reactions.

⯁ CORE CONCEPT
The indicator continuously tracks:
  • The most recent swing high and swing low over a configurable swing window.
  • How long price has been developing since each swing point.
  • Dynamic moving averages whose length grows with the swing itself.
    istantanea


As long as price respects the current swing direction, the bands extend and adapt.
When structure breaks, the system resets and starts forming new swing-based bands.

⯁ SWING DETECTION LOGIC
  • A Swing High is detected when price forms a local maximum relative to the swing lookback.
  • A Swing Low is detected when price forms a local minimum relative to the swing lookback.
  • Direction flips when price transitions from forming highs to forming lows, or vice versa.

istantanea
Each confirmed swing is marked on the chart, giving clear structural context.

⯁ ADAPTIVE BAND CONSTRUCTION
  • Upper bands are derived from swing highs.
  • Lower bands are derived from swing lows.
  • Band length dynamically increases as the swing develops.
  • Multiple MA types can be used (SMA, EMA, SMMA/RMA, WMA, VWMA).
    istantanea


ATR is applied as an offset to create upper and lower envelopes around each band, forming a volatility-aware structure channel.
istantanea


⯁ VOLATILITY FILTERING
  • If the band moves too aggressively relative to ATR, it is temporarily disabled.
  • This prevents unstable or noisy bands during sudden expansions.
  • Bands only remain active when price structure is stable.
    istantanea


This logic keeps the indicator focused on meaningful swings rather than short-term spikes.

⯁ REACTION & SIGNAL LOGIC
  • Sell signals appear when price crosses down from the upper swing band after sufficient stabilization.
    istantanea
  • Buy signals appear when price crosses up from the lower swing band after sufficient stabilization.
    istantanea
  • Cooldown logic prevents signal clustering.


Signals are designed as structure reactions, not momentum breakouts.

⯁ VISUAL STRUCTURE CLARITY
  • Separate bullish and bearish bands with customizable colors.
  • Optional band envelopes for visual depth.
  • Clear swing labels marking structural turning points.
  • Diamond markers highlight reaction zones.
    istantanea


The visualization emphasizes where price reacts to structure rather than where it accelerates.

⯁ HOW TO USE
  • Use upper bands as dynamic resistance during bearish or corrective phases.
  • Use lower bands as dynamic support during bullish phases.
  • Combine band reactions with higher-timeframe trend direction.
  • Look for confirmations near bands rather than mid-range entries.


The indicator works best as a structure framework rather than a standalone signal generator.

⯁ IDEAL MARKET CONDITIONS
  • Trending markets with clear swing development.
  • Markets transitioning from impulse to correction.
  • Crypto, forex, indices, and liquid stocks.


⯁ CONCLUSION
Swing Structure Bands offers a structurally grounded alternative to traditional moving average channels.
By anchoring bands to real swing behavior and adapting dynamically over time, it provides traders with a clearer view of where price is reacting, pausing, or potentially reversing within the broader market structure.

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.