OPEN-SOURCE SCRIPT

Swing Failure Pattern [ SFP ] - FloAlgo

10 299
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:
  • 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 อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน