OPEN-SOURCE SCRIPT
Protected Swings [LuxAlgo]

The Protected Swings indicator identifies and confirms high-probability structural levels based on the interaction between liquidity sweeps, Fair Value Gaps (FVG), and Change in State of Delivery (CISD) logic. This tool aims to highlight "protected" highs and lows that are expected to remain intact during trend continuations or market reversals.
🔶 USAGE
The Protected Swings tool is designed to provide clear invalidation levels for stop placement and to help traders avoid false reversals by waiting for candle-body confirmation through specific price series.
🔹 Trend Reversals
A reversal setup occurs when the market sweeps a major liquidity level (such as a previous swing high or low) or taps into a high-timeframe FVG.
🔹 Trend Continuation
Once Protected Swings are established, subsequent "stepping stones" often form. In a bearish trend, new PSHs will form as price wicks into internal FVGs and then closes back below the candle series that created the retracement high. These levels serve as trailing stop-loss points or areas to look for refined lower-timeframe entries.
🔹 Entry Refinement
Traders can use Protected Swings to refine Risk:Reward. When a higher-timeframe protected level is confirmed, users can drop to a lower timeframe and wait for a secondary protected swing to form. The "Confirmation Level" shown by the indicator represents the exact price point that must be breached to validate the "protected" status of that swing.
🔶 DETAILS
The script follows a multi-step logic to confirm Protected Swings:
🔹 Liquidity Sweeps
The indicator tracks structural pivots (Fractals) based on the "Sweep Sensitivity" setting. A sweep is detected only when the price wick exceeds a previous pivot high or low, but the candle body remains within the previous extreme. This "wick-only" break suggests liquidity is being grabbed (Stop Run) rather than a displacement break of structure occurring.
🔹 FVG Mitigations
The script detects Fair Value Gaps (3-candle imbalances). If enabled, a swing point is considered a candidate for a Protected Swing if it trades into an active FVG, even if a liquidity sweep of a major pivot did not occur.
🔹 Change in State of Delivery (CISD)
The core confirmation logic (CISD) requires the price to close through the "series."
The labels (PSL/PSH) only appear once a candle body closes past this level, ensuring the "State of Delivery" has shifted.
🔶 SETTINGS
🔹 Logic Settings
🔹 Visualization
🔶 USAGE
The Protected Swings tool is designed to provide clear invalidation levels for stop placement and to help traders avoid false reversals by waiting for candle-body confirmation through specific price series.
🔹 Trend Reversals
A reversal setup occurs when the market sweeps a major liquidity level (such as a previous swing high or low) or taps into a high-timeframe FVG.
- A Protected Swing High (PSH) forms after a sweep of a high followed by a close below the opening price of the up-close candle series that created that high. This suggests a shift to a bearish regime.
- A Protected Swing Low (PSL) forms after a sweep of a low followed by a close above the opening price of the down-close candle series that created that low. This suggests a shift to a bullish regime.
🔹 Trend Continuation
Once Protected Swings are established, subsequent "stepping stones" often form. In a bearish trend, new PSHs will form as price wicks into internal FVGs and then closes back below the candle series that created the retracement high. These levels serve as trailing stop-loss points or areas to look for refined lower-timeframe entries.
🔹 Entry Refinement
Traders can use Protected Swings to refine Risk:Reward. When a higher-timeframe protected level is confirmed, users can drop to a lower timeframe and wait for a secondary protected swing to form. The "Confirmation Level" shown by the indicator represents the exact price point that must be breached to validate the "protected" status of that swing.
🔶 DETAILS
The script follows a multi-step logic to confirm Protected Swings:
🔹 Liquidity Sweeps
The indicator tracks structural pivots (Fractals) based on the "Sweep Sensitivity" setting. A sweep is detected only when the price wick exceeds a previous pivot high or low, but the candle body remains within the previous extreme. This "wick-only" break suggests liquidity is being grabbed (Stop Run) rather than a displacement break of structure occurring.
🔹 FVG Mitigations
The script detects Fair Value Gaps (3-candle imbalances). If enabled, a swing point is considered a candidate for a Protected Swing if it trades into an active FVG, even if a liquidity sweep of a major pivot did not occur.
🔹 Change in State of Delivery (CISD)
The core confirmation logic (CISD) requires the price to close through the "series."
- For a Bullish Protected Swing, the script identifies the series of consecutive down-close candles leading into the low. The opening price of the first candle in that down-series becomes the Confirmation Level.
- For a Bearish Protected Swing, it identifies the consecutive up-close candles. The opening price of the first candle in that up-series becomes the level.
The labels (PSL/PSH) only appear once a candle body closes past this level, ensuring the "State of Delivery" has shifted.
🔶 SETTINGS
🔹 Logic Settings
- Sweep Sensitivity: Defines the number of bars required on both sides to confirm a structural pivot level to be used for detecting sweeps.
- Include FVG Mitigations: When enabled, swings that tap into imbalances can trigger protected swing labels.
- FVG Search Lookback: Determines how many bars back the script searches for active imbalances to use as context.
🔹 Visualization
- Show Labels: Toggles the PSL (Protected Swing Low) and PSH (Protected Swing High) labels.
- Show Confirmation Levels: Displays the horizontal lines representing the candle series opening price that triggered the confirmation.
- Show Fair Value Gaps: Visualizes active imbalances on the chart.
- Highlight Liquidity Sweeps: Highlights the specific portion of the wick that exceeded the previous structural pivot.
- Colors: Customization for bullish and bearish elements and transparency for zones.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Build your own edge with AI: luxalgo.com
All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
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.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Build your own edge with AI: luxalgo.com
All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
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.