Advanced Fair Value Gap Detection Strategy with Dynamic Risk Management and Fixed Take Profit
This is a trading strategy based on Fair Value Gap (FVG) detection, combining dynamic risk management with fixed take profit targets. Operating on a 15-minute timeframe, the strategy identifies potential trading…

Overview
This is a trading strategy based on Fair Value Gap (FVG) detection, combining dynamic risk management with fixed take profit targets. Operating on a 15-minute timeframe, the strategy identifies potential trading opportunities by detecting price gaps in the market. According to backtest data from November 2023 to August 2024, the strategy achieved a net profit of 284.40% with 153 total trades, maintaining a win rate of 71.24% and a profit factor of 2.422.
Strategy Principle
The core mechanism revolves around detecting Fair Value Gaps by monitoring price relationships across three consecutive candles:
- Bullish FVG: When the high of the middle candle is below the low of the first candle
- Bearish FVG: When the low of the middle candle is above the high of the first candle
- Entry signals are controlled by an FVG threshold parameter
- Risk control uses a fixed percentage (1%) of account equity as stop loss
- Take profit is set at a fixed 50 points
Strategy Advantages
- Scientific risk management: Uses account equity percentage for stop loss
- Clear trading rules: Fixed take profit targets eliminate subjective judgment
- Excellent performance: High win rate and profit factor indicate strategy stability
- Simple implementation: Clear code logic, easy to understand and maintain
- High adaptability: Can be adjusted for different market conditions
Strategy Risks
- Market volatility risk: Fixed point take profit may be inflexible in highly volatile markets
- Slippage risk: Frequent trading may lead to higher slippage costs
- Parameter dependency: Performance heavily relies on FVG threshold settings
- False breakout risk: Some FVG signals might be false breakouts
- Money management risk: Fixed percentage stop loss might lead to quick drawdowns
Optimization Directions
- Introduce volatility indicators for dynamic take profit adjustment
- Add trend filters to avoid ranging market trades
- Develop multiple timeframe confirmation mechanism
- Optimize position sizing algorithm with floating position system
- Add trading time filters to avoid high volatility periods
- Develop signal strength scoring system for high-quality trade selection
Summary
This strategy demonstrates impressive results by combining Fair Value Gap theory with scientific risk management. The high win rate and stable profit factor indicate its practical value. Through the suggested optimization directions, there is potential for further improvement. Traders are advised to conduct thorough parameter optimization and backtesting before live implementation.
Source Pine Script
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-28 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Fair Value Gap Strategy with % SL and Fixed TP", overlay=true, initial_capital=500, default_qty_type=strategy.fixed, default_qty_value=1)
// Parameters
fvgThreshold = input.float(0.5, "FVG Threshold (%)", minval=0.1, step=0.1)
// Fixed take profit in pips
takeProfitPips = 50
// Function to convert pips to price
pipsToPriceChange(pips) =>
syminfo.mintick * pips * 10
// Function to detect Fair Value Gap
detectFVG(dir) =>
gap = 0.0
if dir > 0 // Bullish FVG
gap := low[2] - high[1]
else // Bearish FVG
gap := low[1] - high[2]
math.abs(gap) > (close * fvgThreshold / 100)
// Detect FVGs
bullishFVG = detectFVG(1)
bearishFVG = detectFVG(-1)
// Entry conditions
longCondition = bullishFVG
shortCondition = bearishFVG
// Calculate take profit level
longTakeProfit = strategy.position_avg_price + pipsToPriceChange(takeProfitPips)
shortTakeProfit = strategy.position_avg_price - pipsToPriceChange(takeProfitPips)
// Calculate stop loss amount (5% of capital)
stopLossAmount = strategy.equity * 0.01
// Execute trades
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
// Set exit conditions
if (strategy.position_size > 0)
strategy.exit("Long TP", "Long", limit=longTakeProfit)
strategy.close("Long SL", when=strategy.openprofit < -stopLossAmount)
else if (strategy.position_size < 0)
strategy.exit("Short TP", "Short", limit=shortTakeProfit)
strategy.close("Short SL", when=strategy.openprofit < -stopLossAmount)
// Plot signals
plotshape(longCondition, "Buy Signal", location = location.belowbar, color = color.green, style = shape.triangleup, size = size.small)
plotshape(shortCondition, "Sell Signal", location = location.abovebar, color = color.red, style = shape.triangledown, size = size.small)Published by ChaoZhang on the FMZ strategy square · last modified 2024-11-29. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Advanced-Fair-Value-Gap-Detection-Strategy-with-Dynamic-Risk-Management-and-Fixed-Take-Profit.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- 5 Day Moving Average Channel Breakout Strategy Combined With Mileage ConceptPine Script · Breakout · 1d
- ATR Trailing Stops StrategyPine Script · Breakout · 1h
- ATR Trend Breakout StrategyPine Script · Breakout · 1d
- Adaptive Bollinger Breakout with Moving Average Quantitative Strategy SystemPine Script · Breakout · 1h
- Adaptive Channel Breakout StrategyPine Script · Breakout · 1d
- Adaptive Multi Period Trading Strategy Based on Wave Trend Momentum BreakoutPine Script · Breakout · 2h