OPEN-SOURCE SCRIPT
Swing Failure Pattern [ SFP ] - FloAlgo

This indicator detects Swing Failure Patterns (SFP) — a Smart Money Concepts technique that identifies liquidity sweeps followed by a Change in State of Delivery (CISD), signaling potential price reversals.
How It Works
The script operates in three stages:
Exit System — 5-Layer Logic
Rather than relying on a fixed take profit, this script uses a dynamic multi-layer exit system designed to protect capital and lock in gains:
Visual Elements
Key Settings
ParameterDescriptionPivot Detection LengthSensitivity of pivot high/low detectionMax Pivot EdgeMaximum bar distance for a valid sweepPatienceMax bars between sweep and CISD for signal confirmationTrend Noise FilterTolerance ratio to filter weak CISD movesTrailing Stop MultiplierATR multiplier controlling trailing stop tightnessMin Bars Before TrailingGrace period before trailing stop activates.
How It Works
The script operates in three stages:
- Liquidity Sweep Detection — Identifies when price briefly breaks above a pivot high or below a pivot low, sweeping resting liquidity beyond those levels.
- CISD Confirmation — Validates the sweep by detecting a Change in State of Delivery: a candle close that reverses back through a key open level, confirming institutional rejection.
- Signal Trigger — A bullish or bearish SFP signal is confirmed only when both the sweep and CISD occur within the defined patience window, reducing false positives significantly.
Exit System — 5-Layer Logic
Rather than relying on a fixed take profit, this script uses a dynamic multi-layer exit system designed to protect capital and lock in gains:
- Initial Stop Loss — Set at the high/low of the signal candle for immediate invalidation
- Trailing Stop — Tracks extreme price movement and trails by ATR × multiplier, activating after a minimum number of bars to avoid premature exits
- Reversal Candle — Exits on an opposing engulfing candle once the trade is in motion
- Timeout — Hard exit after a maximum number of bars
- Trend Flip — Exits if CISD confirms a full trend reversal against the position
Visual Elements
- Dashed lines marking swept pivot levels
- Solid CISD level lines from origin to signal bar
- Dotted stop loss projection lines
- Dynamic trailing stop plotted as a step line
- Bar coloring active while a signal is live
- ▲ / ▼ signal labels on the chart
Key Settings
ParameterDescriptionPivot Detection LengthSensitivity of pivot high/low detectionMax Pivot EdgeMaximum bar distance for a valid sweepPatienceMax bars between sweep and CISD for signal confirmationTrend Noise FilterTolerance ratio to filter weak CISD movesTrailing Stop MultiplierATR multiplier controlling trailing stop tightnessMin Bars Before TrailingGrace period before trailing stop activates.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。