Strategy vault / Trend following
Adaptive FVG Detection and MA Trend Trading Strategy with Dynamic Resistance
This strategy is a comprehensive trading system that combines Fair Value Gap (FVG) detection, moving average trend determination, and dynamic resistance levels. The strategy identifies FVG formation across different…

Overview
This strategy is a comprehensive trading system that combines Fair Value Gap (FVG) detection, moving average trend determination, and dynamic resistance levels. The strategy identifies FVG formation across different timeframes, integrates moving average trend direction, and executes trades upon reversal signals. The system also includes dynamic stop-loss and profit targets based on historical highs.
Strategy Principles
The core logic includes the following key components:
- FVG Detection: Identifies bullish and bearish fair value gaps within specified timeframes (default 1 hour)
- Trend Determination: Uses 20-period moving average to assess market trend direction
- Reversal Confirmation: Evaluates market reversal signals through candlestick patterns
- Dynamic Resistance: Utilizes recent highs as resistance levels and profit targets
- Risk Management: Implements percentage-based stop-loss protection
Strategy Advantages
- Multi-dimensional Analysis: Combines price patterns, trends, and market structure
- High Adaptability: Can adjust parameters in different market environments
- Controlled Risk: Features clear stop-loss and profit targets
- Visual Support: Provides graphical display of FVG zones and key price levels
- Complete Logic: Includes a comprehensive system for entry, exit, and risk management
Strategy Risks
- Timeframe Dependency: Different timeframes may generate conflicting signals
- Market Volatility: Severe fluctuations may trigger frequent stop-losses
- Parameter Sensitivity: Strategy performance heavily depends on parameter settings
- Trend Dependency: May underperform in ranging markets
- Signal Lag: Moving averages have inherent lag
Strategy Optimization Directions
- Introduce Volatility Adaptation: Adjust stop-loss and profit targets based on market volatility
- Add Filtering Conditions: Include volume or other technical indicators for confirmation
- Optimize Timeframes: Test different timeframe combinations for effectiveness
- Improve Trend Determination: Use multiple moving averages or other trend indicators
- Enhance Reversal Confirmation: Incorporate additional pattern recognition methods
Summary
This is a comprehensive strategy that integrates multiple trading concepts, seeking high-probability trading opportunities through the combination of FVG, trends, and price patterns. The strategy's strengths lie in its systematic approach and risk control, but attention must be paid to parameter optimization and market environment adaptability. Through the suggested optimization directions, there is room for further strategy improvement.
Source Pine Script
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-27 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("SMC FVG Entry Strategy with Retest", overlay=true)
// Parametreler
stopLossPercent = input(2, title="Stop Loss (%)") / 100
lookbackPeriod = input(50, title="Güçlü Direnç İçin Geriye Dönük Süre")
fvgLength = input.timeframe("60", title="FVG Zaman Dilimi") // 1 saatlik zaman dilimi
maPeriod = input(20, title="MA Dönemi") // Trend yönü için MA dönemi
// FVG'leri Hesapla
var float fvgLow = na
var float fvgHigh = na
var bool fvgFilled = false
// Seçilen zaman diliminde FVG'leri kontrol et
if (ta.change(time(fvgLength)))
bull_fvg = low > high[2] and close[1] > high[2]
bear_fvg = high < low[2] and close[1] < low[2]
if (bull_fvg)
fvgLow := low[2]
fvgHigh := high
fvgFilled := true
else if (bear_fvg)
fvgLow := low
fvgHigh := high[2]
fvgFilled := true
// Trend Yönü Kontrolü (MA kullanarak)
ma = ta.sma(close, maPeriod)
trendUp = close > ma
trendDown = close < ma
// Dönüş Mumu Kontrolü
bullishReversal = close > open and close[1] < open[1] and fvgFilled and close > fvgHigh
bearishReversal = close < open and close[1] > open[1] and fvgFilled and close < fvgLow
// İlk güçlü direnç noktası
resistanceLevel = ta.highest(high, lookbackPeriod)
// Giriş Koşulları
if (bullishReversal and trendUp)
entryPrice = close
stopLoss = entryPrice * (1 - stopLossPercent)
takeProfit = resistanceLevel
strategy.entry("Long", strategy.long)
strategy.exit("TP", "Long", limit=takeProfit, stop=stopLoss)
if (bearishReversal and trendDown)
entryPrice = close
stopLoss = entryPrice * (1 + stopLossPercent)
takeProfit = resistanceLevel
strategy.entry("Short", strategy.short)
strategy.exit("TP", "Short", limit=takeProfit, stop=stopLoss)
// FVG'leri Grafik Üzerinde Göster
// if (fvgFilled)
// var box fvgBox = na
// if (na(fvgBox))
// fvgBox := box.new(left=bar_index[1], top=fvgHigh, bottom=fvgLow, right=bar_index, bgcolor=color.new(color.green, 90), border_color=color.green)
// else
// box.set_top(fvgBox, fvgHigh)
// box.set_bottom(fvgBox, fvgLow)
// box.set_left(fvgBox, bar_index[1])
// box.set_right(fvgBox, bar_index)
// Direnç Noktasını Göster
plot(resistanceLevel, color=color.blue, title="Direnç Noktası", linewidth=2)
plot(ma, color=color.red, title="Hareketli Ortalama", linewidth=2)
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/Adaptive-FVG-Detection-and-MA-Trend-Trading-Strategy-with-Dynamic-Resistance.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
- ADX MA and EMA Long Only Trend Tracking StrategyPine Script · Trend following · 1d
- ATR and Moving Average Crossover Hybrid StrategyPine Script · Trend following · 1h
- Adaptive Risk Management Strategy Based on Dynamic ATR and Moving Average CrossoverPine Script · Trend following · 2h
- Adaptive Trading Strategy Based on Stochastic RSI Dual Line CrossoverPine Script · Trend following · 4h
- Adaptive Volatility Based Trend Following Short Strategy with Time Delay and Stop Loss ProtectionPine Script · Trend following · 2m
- BB Percentage Index Trend Fading StrategyPine Script · Trend following · 1h