Swing Failure Pattern (SFP) - Advanced & ImprovedSwing Failure Pattern (SFP) automatically detects liquidity sweeps on your chart — bars that wick past a prior swing high or low and close back inside it — and marks them with labels, swept level lines, and optional retest tracking.
=================================
WHAT IS AN SFP?
Every significant swing high and low on your chart has a cluster of orders sitting just beyond it. Stop losses from traders who are long, buy stops from traders waiting for a breakout, limit orders placed at round numbers. All of that sitting at one level is called liquidity.
An SFP is what happens when the market reaches that level, triggers all those orders, and then immediately reverses. Price makes a new high or low — just enough to sweep the liquidity — then snaps back and closes on the other side of the level.
Bullish SFP — wick below a prior swing low, close back above it. The sell stops below that level got triggered. The sellers who just got filled are now trapped. Price is labeled below the wick.
Bearish SFP — wick above a prior swing high, close back below it. The buy stops above that level got triggered. The buyers who just got filled are now trapped. Price is labeled above the wick.
SFP+ and SFP++ — the same wick swept 2 or 3 stacked swing levels at once. More liquidity was grabbed in a single move, which tends to produce a stronger and more sustained reversal.
=================================
HOW THE DETECTION WORKS
The indicator tracks the most recent swing highs and lows using pivot detection (configurable lookback, stored up to max_age days). Each closed bar is checked against all stored pivots:
The wick must exceed the pivot level by at least the minimum sweep size (ATR-based) to filter out micro-wicks that barely graze the level.
The close must reject back past the swept level with a minimum close position (top or bottom X% of the bar), filtering weak closes near the middle.
Optionally, the bar must have above-average volume — real stop hunts typically show a volume spike.
=================================
WHEN IT DOES NOT WORK
An SFP is a liquidity event, not a reversal guarantee. Two conditions reduce its reliability significantly:
Trading against a strong trend. A bearish SFP in the middle of a powerful uptrend often produces only a brief pause before the move continues. The stop hunt happened, but the underlying demand is too strong to reverse. The HTF Trend Filter setting exists for this reason — enabling it filters SFPs that go against the higher timeframe EMA direction.
No supporting context at the level. An SFP that fires at a random mid-range price tends to fail more often than one that occurs at a meaningful confluence of levels — a weekly high, a significant VWAP, a well-established volume node, or a clean structural area that multiple timeframes agree on. The signal is the same but the odds are different. Using this indicator alongside tools that measure level significance will separate the high-quality setups from the noise.
=================================
SETTINGS
Pivot Detection
Intraday pivot bars — confirmation bars required on each side for intraday timeframes (1m to 4H). Default 8.
HTF pivot bars — confirmation bars for Daily and above. Default 3. Kept lower because daily swings are structurally significant with less confirmation needed.
Max pivots stored — how many recent swing levels are tracked per side. Default 5.
Max pivot age (days) — levels older than this are expired. Default 20.
Filters
Min sweep size — wick must exceed the level by at least this ATR multiple.
Min close position % — for bullish SFP, close must be in the top X% of the bar. For bearish, the bottom X%.
Volume confirmation — optionally require above-average volume on the SFP bar.
HTF Trend Filter
When enabled, bullish SFPs only show during uptrends and bearish SFPs only during downtrends, defined by price relative to a configurable EMA on a higher timeframe.
Session Filter
Optionally restrict signals to the London open and NY open windows (UTC hours, fully configurable). SFPs during these windows tend to be institutionally driven rather than low-liquidity noise.
Retest Tracking
After an SFP fires, the swept level is stored. If price later returns to that level and holds, a small R label marks the retest candle. The retest is often a cleaner entry than the SFP candle itself.
Display
Draw swept level lines — dashed line from the original pivot bar to the SFP bar, showing which level was grabbed.
Show tracked pivot levels — draws all currently tracked pivots as dashed lines so you can watch levels in real time before an SFP forms.
Remove pivot when swept — cleans up the level from storage once it has been used.
=================================
RECOMMENDED TIMEFRAME
Works on all timeframes. Pivot bars auto-adjust between intraday and HTF values. Most actionable on 1H to 4H for intraday setups and Daily for swing trading.
Indicador Pine Script®






















