🪙
 Get student discount & enjoy best sellers ~$7/week

Swing Failure Pattern (SFP)

The Swing Failure Pattern (SFP) is a powerful price action indicator that helps traders spot potential reversals by identifying failed breakouts at key swing highs or lows. This comprehensive guide explores the SFP in depth, covering its mechanics, mathematical foundation, coding implementations, and practical trading strategies. Whether you are a beginner or a seasoned trader, mastering the SFP can enhance your ability to avoid false breakouts and improve your trade timing. Read on to discover how to use, code, and optimize the SFP for consistent trading success.

1. Hook & Introduction

Imagine you are watching a major support level on your favorite currency pair. Price dips below, triggering stop-losses and luring breakout traders. Suddenly, the market snaps back above support, leaving breakout traders trapped and fueling a sharp reversal. This is the essence of the Swing Failure Pattern (SFP). In this article, you will learn how to identify, trade, and code the SFP, gaining a robust tool for catching reversals and avoiding common trading traps.

2. What is the Swing Failure Pattern (SFP)?

The Swing Failure Pattern is a price action setup that signals a failed attempt to break a key swing high or low. It occurs when price briefly breaches a previous swing point but fails to hold beyond it, quickly reversing direction. SFPs are used to spot liquidity grabs, false breakouts, and potential reversals. The pattern is popular among professional traders for its reliability in range-bound and mean-reverting markets.

  • Bullish SFP: Price dips below a swing low, then closes back above it.
  • Bearish SFP: Price spikes above a swing high, then closes back below it.

SFPs are most effective when combined with other confirmation tools such as volume, momentum indicators, or support/resistance analysis.

3. Anatomy of the SFP: Key Components

To understand the SFP, break it down into its core elements:

  • Swing High/Low: A recent local maximum or minimum in price.
  • Breakout Attempt: Price moves beyond the swing point, triggering stops or breakout entries.
  • Failure & Reversal: Price fails to sustain beyond the swing, closing back inside the prior range.

The SFP exploits the psychology of trapped traders. When price reverses after a failed breakout, those who entered on the breakout are forced to exit, fueling the reversal move.

4. Mathematical Formula & Calculation

The SFP is defined by a simple yet effective set of rules. Here is the step-by-step calculation:

  • Identify the most recent swing high (for bearish SFP) or swing low (for bullish SFP).
  • Wait for price to break above the swing high (or below the swing low).
  • Confirm that price closes back below the swing high (or above the swing low).

Bearish SFP Formula: If high > swingHigh and close < swingHigh, a bearish SFP is detected.
Bullish SFP Formula: If low < swingLow and close > swingLow, a bullish SFP is detected.

These rules can be implemented in any programming language or trading platform.

5. Real-World Example: SFP in Action

Consider a stock with a recent swing high at $150. Price rallies to $152, triggering breakout buys, but then closes the day at $148. This is a textbook bearish SFP. The failed breakout traps buyers, and the reversal often leads to a sharp decline as they exit their positions.

  • Step 1: Identify swing high at $150.
  • Step 2: Price spikes to $152 (breakout attempt).
  • Step 3: Price closes at $148 (failure and reversal).

Traders can use this signal to enter short positions with stops above the failed swing high.

6. Coding the SFP: Multi-Language Implementations

Implementing the SFP in code allows for systematic backtesting and automation. Below are real-world Code Example, following the required template:

// C++ Example: Detect SFP in OHLC data
#include <vector>
struct Candle { double high, low, close; };
std::vector<bool> detectSFP(const std::vector<Candle>& candles, int swingLen) {
  std::vector<bool> signals(candles.size(), false);
  for (size_t i = swingLen; i + swingLen < candles.size(); ++i) {
    double swingHigh = candles[i-swingLen].high;
    double swingLow = candles[i-swingLen].low;
    if (candles[i].high > swingHigh && candles[i].close < swingHigh)
      signals[i] = true; // Bearish SFP
    if (candles[i].low < swingLow && candles[i].close > swingLow)
      signals[i] = true; // Bullish SFP
  }
  return signals;
}
# Python Example: Detect SFP in OHLCV data
def detect_sfp(candles, swing_len=5):
    signals = []
    for i in range(swing_len, len(candles) - swing_len):
        swing_high = max(c['high'] for c in candles[i-swing_len:i+swing_len+1])
        swing_low = min(c['low'] for c in candles[i-swing_len:i+swing_len+1])
        c = candles[i]
        bearish = c['high'] > swing_high and c['close'] < swing_high
        bullish = c['low'] < swing_low and c['close'] > swing_low
        signals.append({'index': i, 'bearish': bearish, 'bullish': bullish})
    return signals
// Node.js Example: Detect SFP in OHLCV array
function detectSFP(candles, swingLen = 5) {
  const signals = [];
  for (let i = swingLen; i < candles.length - swingLen; i++) {
    const swingHigh = Math.max(...candles.slice(i - swingLen, i + swingLen + 1).map(c => c.high));
    const swingLow = Math.min(...candles.slice(i - swingLen, i + swingLen + 1).map(c => c.low));
    const c = candles[i];
    const bearish = c.high > swingHigh && c.close < swingHigh;
    const bullish = c.low < swingLow && c.close > swingLow;
    signals.push({ index: i, bearish, bullish });
  }
  return signals;
}
// Pine Script v5 Example: Swing Failure Pattern (SFP) Detector
//@version=5
indicator("Swing Failure Pattern (SFP)", overlay=true)
swingLen = input.int(5, title="Swing Length")
swingHigh = ta.pivothigh(high, swingLen, swingLen)
swingLow = ta.pivotlow(low, swingLen, swingLen)
bearishSFP = not na(swingHigh) and high > swingHigh and close < swingHigh
bullishSFP = not na(swingLow) and low < swingLow and close > swingLow
plotshape(bearishSFP, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="Bearish SFP")
plotshape(bullishSFP, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Bullish SFP")
// MetaTrader 5 Example: SFP Detection
void DetectSFP(double &high[], double &low[], double &close[], int swingLen, bool &bearish[], bool &bullish[])
{
  int total = ArraySize(high);
  for (int i = swingLen; i < total - swingLen; i++) {
    double swingHigh = high[i-swingLen];
    double swingLow = low[i-swingLen];
    bearish[i] = (high[i] > swingHigh && close[i] < swingHigh);
    bullish[i] = (low[i] < swingLow && close[i] > swingLow);
  }
}

These code snippets allow you to detect SFPs in any market or timeframe. Adjust swingLen for sensitivity.

7. Interpretation & Trading Signals

Interpreting SFPs requires context. Here is how to use them for trading:

  • Bullish SFP: Look for long entries when price dips below support, then closes back above. Place stops below the failed swing low.
  • Bearish SFP: Look for short entries when price spikes above resistance, then closes back below. Place stops above the failed swing high.

Combine SFPs with momentum indicators (like RSI or MACD) or volume spikes for higher probability setups. Avoid trading SFPs in strong trending markets, as false signals are more common.

8. Combining SFP with Other Indicators

SFPs are most effective when used with other technical tools:

  • RSI: Confirm overbought/oversold conditions.
  • MACD: Confirm momentum shifts.
  • VWAP: Add volume-weighted context.
  • Order Blocks: Identify institutional levels.

Example: A bullish SFP at support, with RSI oversold and a MACD bullish crossover, offers a high-probability long setup.

9. Customization & Alerts

Customize the SFP for your trading style:

  • Adjust swingLen to change sensitivity (shorter for more signals, longer for stronger signals).
  • Add volume filters to reduce false positives.
  • Set up alerts for real-time notifications.
// Pine Script: Add alerts
alertcondition(bearishSFP, title="Bearish SFP Alert", message="Bearish SFP detected!")
alertcondition(bullishSFP, title="Bullish SFP Alert", message="Bullish SFP detected!")

Experiment with different parameters to find the optimal settings for your market and timeframe.

10. Practical Trading Strategies with SFP

Here are practical strategies for trading SFPs:

  • Range Trading: Use SFPs to fade false breakouts at range boundaries.
  • Reversal Trading: Enter reversals after failed breakouts at key levels.
  • Scalping: Use SFPs on lower timeframes for quick trades.

Always use stop-losses and confirm with other indicators to manage risk.

11. Backtesting & Performance

Backtesting is essential to validate the SFP's effectiveness. Here is a sample Python backtest setup:

# Python: Simple SFP Backtest
import pandas as pd
results = []
for i, signal in enumerate(signals):
    if signal['bullish']:
        entry = candles[i]['close']
        stop = min(c['low'] for c in candles[i-5:i+1])
        target = entry + (entry - stop)
        win = candles[i+5]['high'] >= target
        results.append(win)
win_rate = sum(results) / len(results)

Typical win rates for SFP strategies range from 45% to 60% with proper filters. SFPs perform best in sideways or mean-reverting markets. In strong trends, false signals increase, so always use confirmation and risk management.

12. Advanced Variations

Advanced traders can enhance the SFP with:

  • Volume Confirmation: Require a volume spike on the failed breakout.
  • Order Flow Analysis: Use footprint charts to spot institutional activity.
  • Multi-Timeframe SFPs: Confirm SFPs on higher timeframes for stronger signals.
  • Options Trading: Use SFPs to time option entries for reversals.

Institutions often use SFPs to trigger liquidity grabs before large moves. Scalpers can use SFPs on 1-minute charts, while swing traders may prefer daily or weekly SFPs.

13. Common Pitfalls & Myths

Beware of these common mistakes:

  • Assuming every failed breakout is an SFP: Wait for a confirmed close beyond the swing point.
  • Over-relying on SFPs: Use them as part of a broader strategy, not in isolation.
  • Ignoring context: SFPs are less reliable in strong trends or illiquid markets.
  • Signal lag: SFPs are reactive, not predictive. Always use stops.

Proper education and backtesting are key to avoiding these pitfalls.

14. Conclusion & Summary

The Swing Failure Pattern is a versatile and powerful reversal indicator. Its strength lies in filtering out false breakouts and providing clear entry and exit signals. SFPs work best in range-bound and mean-reverting markets, especially when combined with volume, momentum, and support/resistance analysis. Avoid over-reliance and always use risk management. Related indicators include RSI, MACD, and Order Blocks. Mastering the SFP can give you an edge in spotting reversals and improving your trading results.

Frequently Asked Questions about Swing Failure Pattern (SFP)

What is the Swing Failure Pattern (SFP) technical indicator?

The SFP is a technical indicator used to identify potential reversals in the market by analyzing swing highs and failures to reach new highs.

How do I use the SFP indicator?

To use the SFP indicator, traders need to identify a swing high and then look for a failure to reach new highs. Momentum analysis is also essential to confirm the reversal signal.

What is momentum analysis in the context of the SFP indicator?

Momentum analysis involves analyzing the rate of change (ROC) or moving averages to determine whether the security is in a bullish or bearish trend.

Can I use the SFP indicator on any security?

The SFP indicator can be used on most securities, but it's essential to ensure that the data is reliable and accurate.

Is the SFP indicator foolproof?

No, the SFP indicator is not foolproof. It's essential to combine it with other technical analysis tools and risk management techniques for optimal results.



How to post a request?

Posting a request is easy. Get Matched with experts within 5 minutes

  • 1:1 Live Session: $60/hour
  • MVP Development / Code Reviews: $200 budget
  • Bot Development: $400 per bot
  • Portfolio Optimization: $300 per portfolio
  • Custom Trading Strategy: $99 per strategy
  • Custom AI Agents: Starting at $100 per agent
Professional Services: Trading Debugging $60/hr, MVP Development $200, AI Trading Bot $400, Portfolio Optimization $300, Trading Strategy $99, Custom AI Agent $100. Contact for expert help.
⭐⭐⭐ 500+ Clients Helped | 💯 100% Satisfaction Rate


Was this content helpful?

Help us improve this article