OPEN-SOURCE SCRIPT
Session SFP

This script is a powerful, multi-timeframe tool designed to identify high-probability Swing Failure Patterns (SFPs) at key historical levels.
Instead of looking for traditional "pivots" (like a 3-bar swing), this indicator finds the actual high and low of a previous higher-timeframe (HTF) bar (e.g., the previous weekly high/low) and waits for a lower-timeframe (LTF) candle to sweep that level and fail.
This allows you to spot liquidity sweeps and potential reversals at significant, structural price points.
How It Works
The indicator's logic is based on a simple, two-timeframe process:
Level Detection: First, it finds the high and low of the previous bar on your chosen "Level Timeframe" (e.g., W for Weekly, D for Daily). It plots these as small 'x' markers on your chart.
SFP Identification: Second, it watches price action on a lower "SFP Timeframe" (e.g., 240 for 4H). A potential SFP is identified when a candle's wick sweeps above a key high or below a key low.
Confirmation: The SFP is only confirmed after the SFP candle closes back below the high (for a bearish SFP) or above the low (for a bullish SFP). It then waits for a set number of "Confirmation Bars" to pass. If price does not close back over the level during this window, the signal is locked in, and a label is printed.
How to Use (Key Settings)
Level Timeframe (Most Important): This is the timeframe for the levels you want to trade. Set this to W to find SFPs of the previous weekly high/low. Set it to D to find SFPs of the previous daily high/low.
SFP Timeframe: This is the timeframe you want to use to find the SFP candle itself. This should be lower than your Level Timeframe (e.g., 240 or 60).
Level Lookback: This controls how many old levels the script will track. A value of 10 on a W Level Timeframe will track the highs and lows of the last 10 weeks.
Confirmation Bars: This is your "patience" filter. It's the number of SFP Timeframe bars that must close without reclaiming the level after the SFP. A value of 0 will confirm the SFP immediately on the candle's close.
Enable Wick % Filter: A quality filter. If checked, this ensures the SFP candle's rejection wick is a significant percentage of the candle's total range.
Chart Visuals
'x' Markers: These are the historical highs and lows from your "Level Timeframe". You can turn these on or off in the settings.
SFP Label: When an SFP is fully confirmed, a label (Bearish SFP or Bullish SFP) will appear, detailing the level that was swept and the timeframes used.
SFP Line: A solid horizontal line is drawn from the 'x' marker to the SFP candle to highlight the sweep.
Colored Boxes (Optional): If you are viewing a chart timeframe lower than your "SFP Timeframe", you can enable background boxes to highlight the exact SFP candle and its confirmation bars.
Instead of looking for traditional "pivots" (like a 3-bar swing), this indicator finds the actual high and low of a previous higher-timeframe (HTF) bar (e.g., the previous weekly high/low) and waits for a lower-timeframe (LTF) candle to sweep that level and fail.
This allows you to spot liquidity sweeps and potential reversals at significant, structural price points.
How It Works
The indicator's logic is based on a simple, two-timeframe process:
Level Detection: First, it finds the high and low of the previous bar on your chosen "Level Timeframe" (e.g., W for Weekly, D for Daily). It plots these as small 'x' markers on your chart.
SFP Identification: Second, it watches price action on a lower "SFP Timeframe" (e.g., 240 for 4H). A potential SFP is identified when a candle's wick sweeps above a key high or below a key low.
Confirmation: The SFP is only confirmed after the SFP candle closes back below the high (for a bearish SFP) or above the low (for a bullish SFP). It then waits for a set number of "Confirmation Bars" to pass. If price does not close back over the level during this window, the signal is locked in, and a label is printed.
How to Use (Key Settings)
Level Timeframe (Most Important): This is the timeframe for the levels you want to trade. Set this to W to find SFPs of the previous weekly high/low. Set it to D to find SFPs of the previous daily high/low.
SFP Timeframe: This is the timeframe you want to use to find the SFP candle itself. This should be lower than your Level Timeframe (e.g., 240 or 60).
Level Lookback: This controls how many old levels the script will track. A value of 10 on a W Level Timeframe will track the highs and lows of the last 10 weeks.
Confirmation Bars: This is your "patience" filter. It's the number of SFP Timeframe bars that must close without reclaiming the level after the SFP. A value of 0 will confirm the SFP immediately on the candle's close.
Enable Wick % Filter: A quality filter. If checked, this ensures the SFP candle's rejection wick is a significant percentage of the candle's total range.
Chart Visuals
'x' Markers: These are the historical highs and lows from your "Level Timeframe". You can turn these on or off in the settings.
SFP Label: When an SFP is fully confirmed, a label (Bearish SFP or Bullish SFP) will appear, detailing the level that was swept and the timeframes used.
SFP Line: A solid horizontal line is drawn from the 'x' marker to the SFP candle to highlight the sweep.
Colored Boxes (Optional): If you are viewing a chart timeframe lower than your "SFP Timeframe", you can enable background boxes to highlight the exact SFP candle and its confirmation bars.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.