Open Source · MIT License

Fair Value Gap
Trading Bot for Gold

Algorithmic XAUUSD Expert Advisor for MetaTrader 5. Quality-scored FVG entries with Order Block confluence and London/NY killzone timing.

View on GitHub Installation Guide →
+48.7%
6-Month Return
45.3%
Win Rate
64
Total Trades
1.5
Risk:Reward
Features

Institutional-Grade Strategy

Every setup is scored on a 0-100 quality scale. Only the best FVGs with Order Block confluence are traded.

Quality Scoring

Each FVG is scored across 5 factors: gap size, displacement, HTF alignment, freshness, and premium/discount zone.

Order Block Confluence

+20 score bonus when FVG overlaps an institutional Order Block. Filters out weak setups automatically.

HTF Trend Filter

H1 EMA 50/200 trend alignment. Only trades in the direction of the higher timeframe bias.

Killzone Timing

London open, NY overlap, and session end filters. Only trades during peak institutional activity windows.

Risk Management

Fixed R:R take-profit, daily loss limit, break-even management, and max trade caps protect your capital.

Open Source

MIT License. Full MQL5 source code included. Modify, extend, or learn from it freely.

Strategy

How It Works

From detection to execution, every step is quality-controlled.

01

FVG Detection

Scans M15 for three-candle imbalance patterns (Fair Value Gaps). Each gap is measured by size relative to ATR and filtered by minimum size threshold.

02

Quality Scoring

Every detected FVG is scored 0-100 across five weighted components: gap size, candle displacement, H1 EMA alignment, zone freshness, and premium/discount positioning.

03

Order Block Confluence

The EA checks for nearby Order Blocks (institutional supply/demand zones). If an OB overlaps the FVG, the score jumps by +20 points.

04

Session Filter

Only activates during London open (07-10 GMT), London/NY overlap (12-16 GMT), or NY session (up to 21 GMT). Peak liquidity windows only.

05

Entry & Management

Places a limit order near the FVG edge (not midpoint) with fixed 1.5 R:R. Moves to break-even at 0.5x ATR profit. Closes all at session end if enabled.

Performance

Backtest Results

XAUUSD.m, M15, 0.01 lot, $10,000 starting balance.

XAUUSD · M15 · 2026

Backtested
Period Start Final Return Win Rate Trades
3-Month (Apr – Jul) $10,000 $10,522 +5.2% 40.0% 35
6-Month (Jan – Jul) $10,000 $14,874 +48.7% 45.3% 64
Optimized parameters: MinScoreFVG=50 · R:R=1.5 · FVGBuffer=3.0 · FixedLot=0.01
Getting Started

Installation

Up and running in under 2 minutes.

01

Download & Copy

Download FvgGold.mq5 from the repo and copy it to your MT5 Experts folder:

# Windows path:
C:\Users\<You>\AppData\Roaming\MetaQuotes\Terminal\<ID>\MQL5\Experts\
02

Compile

Open MetaTrader 5, press F4 to open MetaEditor. Open FvgGold.mq5 and press Compile (F7). Verify: 0 errors.

03

Attach to Chart

Open a XAUUSD M15 chart. Drag FvgGold from the Navigator. Enable Allow Algo Trading. Click OK.

04

Load Optimized Settings (Optional)

In the EA inputs tab, click Load and select FvgGold.set for pre-optimized parameters.

Configuration

Key Parameters

All parameters are configurable. Defaults are optimized for XAUUSD M15.

FVG Detection

FVGTimeframeM15
MinGapSize25
MaxAgeBars20
FVGBuffer3.0

Quality Scoring

MinScoreFVG50
ScoreGapWeight30
ScoreDispWeight30
ScoreHTFWeight20

Risk Management

FixedLot0.01
RiskRewardRatio1.5
DailyLossLimit$5.00
MaxTrades1

Killzone

London07:00 - 10:00
Overlap12:00 - 16:00
NY Close21:00
PreferOverlaptrue
FAQ

Frequently Asked Questions

Common questions about FvgGold.

A Fair Value Gap is a three-candle pattern where candle 1's high is below candle 3's low (bullish) or candle 1's low is above candle 3's high (bearish). The gap between them represents an institutional imbalance that price tends to revisit.
FvgGold is optimized for M15 (15-minute). M5 produces too many low-quality signals. M30 and H1 produce fewer but higher-quality setups. M15 strikes the best balance.
$10,000 for 0.01 lot. The EA uses fixed lot sizing by default. You can adjust FixedLot or switch to risk-based sizing by setting FixedLot=0.
Yes. While optimized for XAUUSD, it works on any symbol with sufficient liquidity. Adjust MinGapSize and FVGBuffer for different instruments.
Backtesting shows R:R = 1.5 is optimal. Higher ratios (2.0+) reduce win rate too much. Lower ratios (1.0) don't compensate for losses.
Always test on a demo account first. Past backtest results do not guarantee future performance. The EA includes a daily loss limit and break-even management to protect capital.
Yes. FvgGold is open source under the MIT License. Use it, modify it, and distribute it freely.

Start Trading Smarter

Free, open-source, and ready to use. Download FvgGold and backtest it yourself.

View on GitHub Download ZIP