Shift Structure Cloud [JOAT]Shift Structure Cloud is an open-source Pine Script v6 overlay that converts confirmed swing structure into a clean adaptive trend cloud. It tracks pivot highs and pivot lows, separates continuation breaks from character shifts, and uses the active structure range to build a dynamic average and multi-layer cloud around price.
The problem it solves is structural context. Many trend tools react only to moving averages or oscillator thresholds. This script anchors its visual state to confirmed market structure first, then uses an adaptive cloud to show whether price is trading above, below, or inside the current structural center. The result is a chart layer that can help separate continuation from transition without relying on future bars.
Core Concepts
1. Confirmed Pivot Structure
The script uses ta.pivothigh() and ta.pivotlow() to confirm swing highs and lows. A pivot is only accepted after the configured right-side confirmation window closes, which means the level is delayed by design but does not depend on unconfirmed future plotting.
pivotHigh = ta.pivothigh(high, pivotLeft, pivotRight)
pivotLow = ta.pivotlow(low, pivotLeft, pivotRight)
if not na(pivotHigh)
structureHigh := pivotHigh
2. BOS and CHoCH Logic
The current structure high and low become break reference levels. A bullish break occurs when price closes above the prior structure high. A bearish break occurs when price closes below the prior structure low. If the break happens against the previous side, it is classified as CHoCH; otherwise it is a continuation BOS.
bullBreakRaw = barstate.isconfirmed and not na(priorHigh) and close > priorHigh and priorClose <= priorHigh
bearBreakRaw = barstate.isconfirmed and not na(priorLow) and close < priorLow and priorClose >= priorLow
bullChoCh = bullBreak and trendSide == -1
bearChoCh = bearBreak and trendSide == 1
3. Adaptive Structure Average
Instead of plotting only fixed swing levels, the script calculates the midpoint between the active structure high and low. The midpoint is then smoothed with an adaptive alpha. When price moves far from the structural center, the average becomes more responsive; when price is balanced, it becomes slower.
structureMid = (activeHigh + activeLow) * 0.5
structureDrift = f_clamp(math.abs(close - structureMid) / legSize, 0.0, 1.0)
adaptAlpha = slowAlpha + (fastAlpha - slowAlpha) * structureDrift
structureAverage := structureAverage + adaptAlpha * (structureMid - structureAverage )
4. Multi-Layer Cloud
The cloud is built from ATR-adjusted bands around the adaptive structure average. Inner, middle, and outer layers give a visual read of compression, transition, and extended distance from structure.
5. Strength-Based Candle Coloring
When enabled, candles are repainted with a gradient based on distance from the structure average. The candle color is informational only; it does not change the underlying chart data.
Features
Confirmed BOS and CHoCH detection: Structural events are gated with barstate.isconfirmed
Adaptive structure average: A dynamic centerline based on active swing range and price drift
Layered trend cloud: Inner, middle, and outer ATR bands visualize distance from structure
Structure high and low levels: Current confirmed swing levels can be shown as reference lines
Gradient candle mode: Optional candle coloring by structural distance
Compact dashboard: Shows side, last shift, strength, bars since shift, and active range
Palette presets: Aqua Rose, Neon Desk, Mint Pulse, and VWAP Field
Alert conditions: Separate alerts for bullish BOS, bearish BOS, bullish CHoCH, and bearish CHoCH
Input Parameters
Visual System:
Palette Preset: Selects the bull and bear color pair
Color Candles: Enables structural candle coloring
Dashboard: Shows or hides the top-right dashboard
Pivot Dots: Shows confirmed pivot dots
Structure Engine:
Pivot Left / Pivot Right: Controls swing confirmation sensitivity
Fast Adapt Length: Fast smoothing response for the adaptive average
Slow Adapt Length: Slow smoothing response for balanced conditions
Cloud ATR Length: ATR length used for cloud width
Cloud Width: Multiplier applied to the cloud distance
BOS and CHoCH Marks: Shows structural event markers
Structure Levels: Shows active swing high and low reference lines
How to Use This Indicator
Step 1: Read the Cloud Side
If price is above the adaptive structure average and the cloud is colored bullish, the current structural state favors upside continuation. If price is below and the cloud is bearish, the state favors downside continuation.
Step 2: Watch CHoCH Events
CHoCH labels mark breaks against the previous structural side. They are useful as transition warnings, not automatic entries.
Step 3: Use the Structure Levels
The active high and low lines show where the next confirmed break could occur. These are the levels the script uses for BOS and CHoCH classification.
Step 4: Combine with Your Own Trigger
This script is designed as a structure and context layer. Use it with your own entry model, risk plan, and market selection process.
Indicator Limitations
Pivot levels confirm after the right-side pivot window closes, so they are intentionally delayed
A fast reversal can occur before a new pivot is confirmed
Cloud distance is ATR-based, so very low volatility markets can compress the visual bands
The script classifies structure; it does not predict future price movement
Originality Statement
Shift Structure Cloud combines confirmed BOS/CHoCH logic, an adaptive structure midpoint, ATR cloud geometry, and strength-colored candles in one original Pine v6 implementation. The script is not a pasted source clone. It rebuilds structure analysis from public Pine mechanics and adds a distinct visual model around the current swing range.
Disclaimer
This script is provided for educational and informational use only. It is not financial advice or a recommendation to buy or sell any financial instrument. Trading involves substantial risk of loss. Signals and structure readings are based on historical chart data and can be wrong in live market conditions. Always use independent analysis and proper risk management.
-Made with passion by jackofalltrades
Pine Script®指標






















