High-Frequency Fair Value Gap Momentum Trading Strategy with EMA and ATR-Based Dynamic Exit

FVG EMA ATR SMA TP SL
Created on: 2025-02-20 15:18:11 Modified on: 2025-02-20 15:18:11
Copy: 0 Number of hits: 548
avatar of ianzeng123 ianzeng123
2
Follow
319
Followers

 High-Frequency Fair Value Gap Momentum Trading Strategy with EMA and ATR-Based Dynamic Exit  High-Frequency Fair Value Gap Momentum Trading Strategy with EMA and ATR-Based Dynamic Exit

Overview

This strategy is a high-frequency trading system based on Fair Value Gaps (FVG). It combines 50-period and 200-period Exponential Moving Averages (EMA) for trend confirmation, while utilizing multiple filtering indicators such as volume and price volatility to enhance signal reliability. The strategy employs a dynamic take-profit and stop-loss mechanism based on Average True Range (ATR) to ensure profits while strictly controlling risks.

Strategy Principles

The core principle is to capture trading opportunities by identifying Fair Value Gaps in price movement. When price exhibits significant gaps that align with the main trend, the strategy considers this imbalance as an indication of continued price movement in that direction. Specifically: 1. Overall trend determination using EMA50 and EMA200 relationship 2. Identification of areas with significantly increased volume (1.5 times above 20-period average) 3. Confirmation of price volatility exceeding normal levels, indicating strong market sentiment 4. Trade execution when FVG appears in the trend direction with all conditions met 5. Implementation of 2x ATR for take-profit and 1.2x ATR for stop-loss, achieving a risk-reward ratio of approximately 1.67

Strategy Advantages

  1. Multiple signal filtering mechanisms significantly improve trading accuracy
  2. Dynamic take-profit and stop-loss settings adapt to different market conditions
  3. Combines trend-following and reversal trading characteristics for profit in various market states
  4. Thoroughly considers market microstructure features like volume and price volatility
  5. Applicable to multiple major currency pairs and different timeframes

Strategy Risks

  1. Potentially inadequate stop-loss levels during extreme market volatility
  2. Some lag in identifying market turning points
  3. Possibility of frequent false signals during consolidation phases
  4. Requires real-time volume monitoring and high-quality data Risk control recommendations:
  • Adjust ATR multipliers to match different market volatility characteristics
  • Add trend filtering conditions to avoid trading in ranging markets
  • Monitor market liquidity changes in real-time

Strategy Optimization Directions

  1. Incorporate additional market microstructure indicators, such as order flow data
  2. Optimize volume filtering thresholds, considering adaptive thresholds
  3. Enhance the take-profit and stop-loss mechanism by introducing trailing stops
  4. Improve market state identification for different parameter settings
  5. Consider adding time filters to avoid trading during inactive periods

Summary

This strategy constructs a comprehensive trading system by combining technical analysis and market microstructure analysis methods. The core advantages lie in its multiple signal confirmation mechanism and dynamic risk control, though parameter optimization is still necessary for specific market conditions. Through continuous improvement and optimization, the strategy shows promise in maintaining stable performance across different market environments.

Strategy source code
/*backtest
start: 2024-02-21 00:00:00
end: 2025-02-01 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/

//@version=5
strategy("Effective FVG Strategy - Forex", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// === Exponential Moving Averages for Faster Trend Detection ===
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
bullishTrend = ema50 > ema200
bearishTrend = ema50 < ema200

// === Volume & Imbalance Filters ===
highVolume = volume > ta.sma(volume, 20) * 1.5  // 1.5x higher than average volume
strongImbalance = math.abs(close - open) > ta.sma(math.abs(close - open), 20)  // Large price movement

// === Fair Value Gap (FVG) Detection ===
fvgUp = low[2] > high[0]  // Bullish FVG
fvgDown = high[2] < low[0]  // Bearish FVG

// Effective FVGs with trend confirmation
validBullFVG = fvgUp and highVolume and strongImbalance and bullishTrend
validBearFVG = fvgDown and highVolume and strongImbalance and bearishTrend

// === ATR-based Take Profit & Stop Loss (Optimized for Forex) ===
atr = ta.atr(14)
longTP = close + (2 * atr)  // TP = 2x ATR
longSL = close - (1.2 * atr)  // SL = 1.2x ATR
shortTP = close - (2 * atr)
shortSL = close + (1.2 * atr)

// === Execute Trades ===
if validBullFVG
    strategy.entry("Long", strategy.long)
    strategy.exit("Long Exit", from_entry="Long", limit=longTP, stop=longSL)

if validBearFVG
    strategy.entry("Short", strategy.short)
    strategy.exit("Short Exit", from_entry="Short", limit=shortTP, stop=shortSL)

// === Plot Buy/Sell Signals ===
plotshape(series=validBullFVG, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", title="BUY Signal")
plotshape(series=validBearFVG, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", title="SELL Signal")

// Highlight Significant FVGs
bgcolor(validBullFVG ? color.new(color.green, 85) : na)
bgcolor(validBearFVG ? color.new(color.red, 85) : na)