Liquidity Sweep and Trend Following Quantitative Trading Strategy

SMA ATR 流动性扫荡 趋势跟踪 止损止盈 波动率 高低点突破 移动平均线
Created on: 2025-08-19 11:48:02 Modified on: 2025-08-19 11:48:02
Copy: 0 Number of hits: 383
avatar of ianzeng123 ianzeng123
2
Follow
319
Followers

 Liquidity Sweep and Trend Following Quantitative Trading Strategy  Liquidity Sweep and Trend Following Quantitative Trading Strategy

Overview

The Liquidity Sweep and Trend Following Quantitative Trading Strategy is a dual technical analysis approach that combines market liquidity sweeps with trend following. This strategy primarily identifies entry signals by recognizing price breakouts of recent highs and lows (liquidity sweeps) along with relative position to moving averages (trend confirmation). The strategy utilizes a Simple Moving Average (SMA) as a trend determination tool and employs Average True Range (ATR) to dynamically set stop-loss and take-profit levels, adapting to changes in market volatility.

Strategy Principles

The core principles of this strategy are based on two key market behaviors: liquidity sweeps and trend direction.

  1. Liquidity Sweep Identification:

    • The strategy uses the swingLookback parameter (default: 3) to define the lookback period for recent highs and lows
    • When price breaks above recent highs, it’s identified as a bullish liquidity sweep (bullSweep)
    • When price breaks below recent lows, it’s identified as a bearish liquidity sweep (bearSweep)
  2. Trend Direction Confirmation:

    • Uses a Simple Moving Average (default period: 20) as trend reference
    • Closing price above the moving average is considered an uptrend
    • Closing price below the moving average is considered a downtrend
  3. Entry Signals:

    • Long entry: Price breaks above recent high (liquidity sweep) and is in an uptrend
    • Short entry: Price breaks below recent low (liquidity sweep) and is in a downtrend
  4. Risk Management:

    • Dynamic stop-loss: Based on ATR (default period: 14), set at 1.5x ATR
    • Dynamic take-profit: Also based on ATR, set at 3x ATR, providing a 2:1 risk-reward ratio
  5. Visualization Components:

    • Trend moving average display
    • Liquidity sweep markers
    • Trend background color
    • Buy/sell signal alerts

Strategy Advantages

  1. Market Structure and Trend Integration: By combining liquidity sweeps (market structure) and moving averages (trend), the strategy can capture more reliable trading signals and avoid false breakouts.

  2. Dynamic Risk Management: Using ATR to adjust stop-loss and take-profit levels allows risk management to adapt to market volatility, providing wider stops in highly volatile markets and tighter stops in less volatile markets.

  3. Simple Yet Effective Parameters: The strategy uses only a few key parameters, such as moving average period, ATR period, stop-loss multiplier, take-profit multiplier, and lookback period, making it easy to understand and optimize.

  4. Rich Visual Feedback: The strategy provides intuitive visual indicators including trend background color, liquidity sweep markers, and moving average line, helping traders quickly assess market conditions.

  5. Built-in Alert Functionality: The strategy integrates buy/sell signal alerts, making it convenient for traders to receive timely notifications of trading opportunities.

  6. Integrated Money Management: The strategy uses account equity percentage for position sizing, defaulting to 10%, ensuring position size adjusts appropriately as the account grows.

Strategy Risks

  1. False Breakout Risk: Despite incorporating trend confirmation, liquidity sweeps can still lead to false breakout signals, especially during highly volatile markets or consolidation periods. Solution: Consider adding additional filtering conditions such as volume confirmation or volatility filters.

  2. Overtrading Risk: When the swingLookback parameter is set too small (such as the default of 3), it may generate too many trading signals. Solution: Adjust this parameter based on the characteristics of the trading instrument and timeframe, or add signal confirmation mechanisms.

  3. Stop-Loss Too Tight/Wide Risk: Fixed ATR multipliers may not be flexible enough in certain market conditions. Solution: Consider dynamically adjusting ATR multipliers based on market state (such as volatility changes or trend strength).

  4. Trend Reversal Risk: Moving averages as lagging indicators may not respond quickly enough during trend reversals. Solution: Consider using more sensitive indicators such as ALMA or dual EMA crossovers to determine trends.

  5. Fixed Risk-Reward Ratio Limitation: The strategy uses fixed ATR multipliers (default 1.5x for stop-loss, 3x for take-profit), not considering support/resistance levels in market structure. Solution: Improve by dynamically adjusting target prices based on market structure.

Strategy Optimization Directions

  1. Multiple Timeframe Analysis: Introducing trend confirmation from higher timeframes can significantly improve strategy reliability. For example, only trading when the trend direction in larger timeframes is consistent can reduce the risk of counter-trend trading.

  2. Dynamic Parameter Adjustment: Dynamically adjust swingLookback, stop-loss, and take-profit multipliers based on market volatility or volume changes. For instance, increase the lookback period in highly volatile markets to reduce false signals.

  3. Add Volume Confirmation: Use volume as a confirmation indicator, only confirming signals when liquidity sweeps are accompanied by increased volume, which can significantly reduce false breakout trades.

  4. Introduce Market Structure Recognition: Enhance the strategy’s understanding of price structure, such as identifying higher highs/lower lows patterns, or identifying support/resistance zones, thereby optimizing entry points and target prices.

  5. Adaptive Moving Averages: Consider using adaptive moving averages (such as KAMA or ALMA) instead of simple moving averages to better adapt to different market conditions.

  6. Time Filters: Add time filters to avoid known inefficient trading sessions, such as sideways periods during Asian sessions or high volatility periods before and after important economic data releases.

  7. Position Management Optimization: The current strategy uses a fixed equity percentage (10%), consider dynamically adjusting position size based on volatility or risk models, or implementing a pyramid scaling strategy.

Summary

The Liquidity Sweep and Trend Following Quantitative Trading Strategy is a comprehensive trading system that combines technical analysis and risk management. By identifying liquidity sweep behaviors in the market and combining them with trend confirmation, the strategy aims to capture high-probability trading opportunities. Its dynamic risk management mechanism uses ATR to adapt to market volatility, providing adaptive stop-loss and take-profit levels.

The main advantages of the strategy lie in its simple yet effective parameter setup and rich visual feedback, making it suitable for traders of all levels. However, the strategy also has risks of false breakouts and overtrading, which can be optimized by adding additional filtering conditions and multiple timeframe analysis.

Future optimization directions include multiple timeframe analysis, dynamic parameter adjustment, volume confirmation, and enhanced market structure recognition. Through these optimizations, the reliability and profitability of the strategy can be further improved, reducing false signals and unnecessary trading frequency.

For traders seeking to combine market structure and trend following methods, this strategy provides a solid foundation framework that can be customized and expanded according to individual risk preferences and trading styles.

Strategy source code
/*backtest
start: 2025-01-01 00:00:00
end: 2025-02-07 00:00:00
period: 15m
basePeriod: 15m
exchanges: [{"eid":"Futures_OKX","currency":"ETH_USDT","balance":5000}]
*/

//@version=5
strategy("Liquidity Sweep & Trend Following BTCUSD (Signals Visible)", overlay=true)

// ==== Inputs ====
length = input.int(20, "Trend MA Length")
atrLength = input.int(14, "ATR Length")
stopLossATR = input.float(1.5, "Stop Loss ATR Multiplier")
takeProfitATR = input.float(3, "Take Profit ATR Multiplier")
swingLookback = input.int(3, "Recent High/Low Lookback") // shorter for more signals

// ==== Indicators ====
ma = ta.sma(close, length)
atr = ta.atr(atrLength)

// ==== Trend Detection ====
trendUp = close > ma
trendDown = close < ma

// ==== Detect Liquidity Sweeps ====
// Relaxed condition
recentHigh = ta.highest(high, swingLookback)
recentLow = ta.lowest(low, swingLookback)

bullSweep = high >= recentHigh
bearSweep = low <= recentLow

// ==== Entry Rules ====
longCondition = bullSweep and trendUp
shortCondition = bearSweep and trendDown

if (longCondition)
    strategy.entry("Long", strategy.long)

if (shortCondition)
    strategy.entry("Short", strategy.short)

// ==== Exit Rules ====
strategy.exit("Exit Long", "Long", stop=close - atr*stopLossATR, limit=close + atr*takeProfitATR)
strategy.exit("Exit Short", "Short", stop=close + atr*stopLossATR, limit=close - atr*takeProfitATR)

// ==== Plot Trend MA ====
plot(ma, color=color.yellow, linewidth=2, title="Trend MA")

// ==== Plot Sweep Markers ====
plotshape(bullSweep, style=shape.triangleup, location=location.abovebar, color=color.green, size=size.small, title="Bull Sweep Marker")
plotshape(bearSweep, style=shape.triangledown, location=location.belowbar, color=color.red, size=size.small, title="Bear Sweep Marker")

// ==== Background Trend Color ====
bgcolor(trendUp ? color.new(color.green, 85) : trendDown ? color.new(color.red, 85) : na)

// ==== Alert Conditions ====
alertcondition(longCondition, title="Buy Signal", message="BTCUSD Buy Signal – Liquidity Sweep + Trend")
alertcondition(shortCondition, title="Sell Signal", message="BTCUSD Sell Signal – Liquidity Sweep + Trend")