← Back to list

I Built FvgGold-EA: An Expert Advisor for XAUUSD Trading

I’ve been working on a project that combines algorithmic trading, technical analysis, and automated risk management: FvgGold-EA, an Expert…

Foeedrs in InfoSec Write-ups · 2026-08-03 12:43 · 0 claps · 3.4 min read
#trade #mt5 #aitrades #scalping
Open on Medium ↗
Wiki topics: BIZ · Business Strategy ECO · Economy · General 💻 · Programming

I Built FvgGold-EA: An Expert Advisor for XAUUSD Trading

I’ve been working on a project that combines algorithmic trading, technical analysis, and automated risk management: FvgGold-EA, an Expert Advisor designed for trading Gold (XAUUSD) on MetaTrader.

🔗 Project: https://foeed.github.io/FvgGold-EA/

The goal was not simply to create a bot that opens and closes trades.

I wanted to build a structured trading system where the logic is clearly defined, risk is controlled, and the strategy can be tested and improved systematically.

Why Gold?

Gold (XAUUSD) is an interesting market for algorithmic trading.

It can provide strong price movements and frequent opportunities, but it can also become extremely volatile around news events and major market sessions.

That makes it a good environment for testing:

  • Entry logic
  • Market structure
  • Stop-loss and take-profit management
  • Risk/reward strategies
  • Position sizing
  • Drawdown control
  • Automated execution

The challenge is finding a balance between capturing opportunities and protecting the account when the market behaves unexpectedly.

The Idea Behind FvgGold-EA

The name comes from Fair Value Gap (FVG) concepts.

The idea is to identify areas where price has moved aggressively and left an imbalance in the market.

Instead of blindly entering whenever an FVG appears, the EA uses predefined conditions to determine whether a setup is worth considering.

The general workflow is:

Market Data → Setup Detection → Entry Validation → Risk Calculation → Trade Execution → Position Management

This structure makes the system easier to test and improve.

Automated Risk Management

One of the most important parts of an Expert Advisor isn’t the entry signal.

It is risk management.

A strategy can have good entries and still destroy an account if position sizing and drawdown are poorly controlled.

For that reason, I designed the EA around controlled risk rather than simply maximizing the number of trades.

The system considers factors such as:

  • Position size
  • Stop-loss
  • Take-profit
  • Risk/reward
  • Account balance
  • Market conditions
  • Existing positions

The objective is simple:

Survive first. Optimize second.

Backtesting

Backtesting is an essential part of developing an automated trading strategy.

Before thinking about live trading, the strategy needs to be evaluated against historical market data.

Some of the metrics I focus on include:

  • Win rate
  • Profit factor
  • Maximum drawdown
  • Net profit
  • Average trade
  • Risk/reward
  • Number of trades
  • Consecutive losses

But one lesson I learned while working on this project is that a high backtest return doesn’t automatically mean a good trading strategy.

A strategy can look incredible on historical data simply because it has been over-optimized.

That’s why robustness matters more than a single impressive backtest.

Avoiding Overfitting

One of the biggest challenges in algorithmic trading is curve fitting.

If you continuously optimize parameters against the same historical dataset, eventually the EA can become extremely good at trading the past while performing poorly on new data.

This is why I want to evaluate FvgGold-EA using approaches such as:

In-Sample Data → Optimization → Out-of-Sample Testing → Forward Testing

The objective is to find parameters that generalize instead of parameters that simply produce the best historical result.

Engineering the EA

Building an automated trading system is also a software engineering problem.

The system needs to handle:

  • Market data
  • Trading conditions
  • Order execution
  • Position management
  • Error handling
  • Risk calculations
  • Broker constraints
  • Strategy state
  • Logging

A trading strategy written on paper is very different from a strategy running automatically against a live market.

Execution matters.

A theoretically perfect entry can still behave differently because of spread, slippage, latency, liquidity, or broker execution conditions.

What’s Next?

FvgGold-EA is still an evolving project.

Some of the areas I’m interested in exploring next are:

1. Market Regime Detection

Gold doesn’t behave the same way in every market condition.

A future version could distinguish between:

  • Trending markets
  • Ranging markets
  • High-volatility periods
  • Low-volatility periods

The strategy could then adapt its behavior accordingly.

2. News-Aware Trading

Major economic events can dramatically affect Gold.

Integrating an economic-calendar/news filter could allow the EA to reduce or disable trading around high-impact events.

3. Advanced Analytics

Another goal is to build better analytics around the EA:

  • Trade distribution
  • Drawdown analysis
  • Session performance
  • Setup performance
  • Long vs short performance
  • Market-condition performance

This would make it easier to understand why the strategy works or fails.

4. Machine Learning

Eventually, machine learning could be used as an additional filtering layer rather than replacing the entire trading strategy.

For example:

Technical Strategy → ML Filter → Risk Engine → Execution

The ML component could estimate whether a detected setup has a sufficiently high probability of success under the current market conditions.

But I don’t want to add AI just because “AI” is trendy.

The model would need to provide measurable improvement through proper out-of-sample and forward testing.

What I Learned

Building FvgGold-EA taught me something important:

Automated trading isn’t about predicting the market perfectly.

It is about designing a system that can operate under uncertainty.

A good trading system needs:

Strategy + Risk Management + Engineering + Testing + Discipline

Not just a profitable backtest.

I’m continuing to experiment with FvgGold-EA and improve the system step by step.

If you’re interested in algorithmic trading, Expert Advisors, quantitative strategies, or the engineering behind automated trading systems, I’d be happy to share more technical details in future posts.

Project

🔗 FvgGold-EA: https://foeed.github.io/FvgGold-EA/

This project is for research and educational purposes. Historical/backtest performance does not guarantee future results. Trading financial markets involves significant risk.


메타데이터
post_id
330c0afa2ae6
slug
i-built-fvggold-ea-an-expert-advisor-for-xauusd-trading-330c0afa2ae6
url
https://medium.com/@foeedrs/i-built-fvggold-ea-an-expert-advisor-for-xauusd-trading-330c0afa2ae6
canonical_url
https://medium.com/@foeedrs/i-built-fvggold-ea-an-expert-advisor-for-xauusd-trading-330c0afa2ae6
author_url
https://medium.com/@foeedrs
status
ok
fetched_at
2026-08-04 12:20:17