Introduction
Gold (XAU/USD) remains one of the most popular instruments among retail and institutional traders alike. Its high volatility, global liquidity, and sensitivity to macroeconomic events make it a prime candidate for automated trading strategies. If you’re looking to start trading gold on autopilot without investing in expensive software upfront, a free MT4 Gold EA (Expert Advisor) might be the perfect solution.
In this article, we’ll explore what a Free Gold EA on MT4 offers, how it works, and what you should look for when choosing one.
What Is an MT4 Gold EA?
An Expert Advisor (EA) is a trading robot built for the MetaTrader 4 (MT4) platform that executes trades automatically based on pre-programmed rules. A Gold EA specifically focuses on trading the XAU/USD pair, often using strategies like:
- Trend following
- Scalping during high volatility
- News-based breakout trading
- Hedging or grid trading
- Arbitrage (in more advanced versions)

MT4 Gold EA Code Simples
// ===== Trend Following EA (Simple Moving Average Crossover) =====
// Description: This EA places a Buy order when the fast MA crosses above the slow MA
// and a Sell order when the fast MA crosses below the slow MA. Best used on H1 or H4.
// Usage: Attach to XAUUSD chart, set MA periods to fit market trend.
input int fastMA = 10;
input int slowMA = 30;
input double lotSize = 0.1;
int start() {
double maFast = iMA(Symbol(), 0, fastMA, 0, MODE_SMA, PRICE_CLOSE, 0);
double maSlow = iMA(Symbol(), 0, slowMA, 0, MODE_SMA, PRICE_CLOSE, 0);
double maFastPrev = iMA(Symbol(), 0, fastMA, 0, MODE_SMA, PRICE_CLOSE, 1);
double maSlowPrev = iMA(Symbol(), 0, slowMA, 0, MODE_SMA, PRICE_CLOSE, 1);
if (maFast > maSlow && maFastPrev <= maSlowPrev && OrdersTotal() == 0) {
OrderSend(Symbol(), OP_BUY, lotSize, Ask, 3, 0, 0, "TrendFollow Buy", 0, 0, clrGreen);
}
if (maFast < maSlow && maFastPrev >= maSlowPrev && OrdersTotal() == 0) {
OrderSend(Symbol(), OP_SELL, lotSize, Bid, 3, 0, 0, "TrendFollow Sell", 0, 0, clrRed);
}
return 0;
}
// ===== Scalping During High Volatility =====
// Description: This EA uses Bollinger Band breakout logic on M1 timeframe.
// Usage: Best during volatile periods. Entry occurs when price crosses upper/lower band.
input double bbDeviation = 2.5;
input int bbPeriod = 20;
int start() {
double upperBand = iBands(Symbol(), 0, bbPeriod, bbDeviation, 0, PRICE_CLOSE, MODE_UPPER, 0);
double lowerBand = iBands(Symbol(), 0, bbPeriod, bbDeviation, 0, PRICE_CLOSE, MODE_LOWER, 0);
double price = iClose(Symbol(), 0, 0);
if (price > upperBand && OrdersTotal() == 0) {
OrderSend(Symbol(), OP_BUY, lotSize, Ask, 3, 0, 0, "Scalp Buy", 0, 0, clrBlue);
}
if (price < lowerBand && OrdersTotal() == 0) {
OrderSend(Symbol(), OP_SELL, lotSize, Bid, 3, 0, 0, "Scalp Sell", 0, 0, clrOrange);
}
return 0;
}
// ===== News-Based Breakout Trading EA =====
// Description: Places BuyStop and SellStop orders before a scheduled news time.
// Usage: Set 'newsTime' to scheduled release, EA places breakout orders beforehand.
input double range = 30; // Distance from current price in points
input int secondsBeforeNews = 30;
input datetime newsTime = D'2025.07.03 08:30';
int start() {
if (TimeCurrent() >= (newsTime - secondsBeforeNews) && TimeCurrent() < newsTime) {
if (OrdersTotal() == 0) {
double buyPrice = Ask + range * Point;
double sellPrice = Bid - range * Point;
OrderSend(Symbol(), OP_BUYSTOP, lotSize, buyPrice, 3, 0, 0, "News Buy", 0, newsTime + 300, clrGreen);
OrderSend(Symbol(), OP_SELLSTOP, lotSize, sellPrice, 3, 0, 0, "News Sell", 0, newsTime + 300, clrRed);
}
}
return 0;
}
// ===== Hedging/Grid Trading EA =====
// Description: Opens Buy and Sell orders spaced apart by 'gridSpacing'. Adds positions up to maxTrades.
// Usage: Attach to chart. Works best in ranging markets. Can be dangerous in trends.
input double gridSpacing = 50;
input int maxTrades = 5;
int start() {
int buys = 0, sells = 0;
for (int i = 0; i < OrdersTotal(); i++) {
OrderSelect(i, SELECT_BY_POS);
if (OrderType() == OP_BUY) buys++;
if (OrderType() == OP_SELL) sells++;
}
if (buys < maxTrades) {
OrderSend(Symbol(), OP_BUY, lotSize, Ask, 3, Ask - gridSpacing * Point, 0, "Grid Buy", 0, 0, clrGreen);
}
if (sells < maxTrades) {
OrderSend(Symbol(), OP_SELL, lotSize, Bid, 3, Bid + gridSpacing * Point, 0, "Grid Sell", 0, 0, clrRed);
}
return 0;
}
// ===== Simplified Arbitrage Signal Detector (Conceptual) =====
// Description: Detects price discrepancies between external FastFeed and broker price.
// Usage: Requires external DLL or socket-feed to provide fastPrice in real-time.
extern double fastPrice = 0;
input double arbitrageThreshold = 15;
int start() {
double brokerPrice = MarketInfo(Symbol(), MODE_ASK);
if (fastPrice - brokerPrice > arbitrageThreshold * Point && OrdersTotal() == 0) {
OrderSend(Symbol(), OP_BUY, lotSize, Ask, 3, 0, 0, "Arb Buy", 0, 0, clrBlue);
}
if (brokerPrice - fastPrice > arbitrageThreshold * Point && OrdersTotal() == 0) {
OrderSend(Symbol(), OP_SELL, lotSize, Bid, 3, 0, 0, "Arb Sell", 0, 0, clrRed);
}
return 0;
}
These robots can help eliminate emotional decision-making, manage trades 24/5, and react faster than a human trader ever could.
Why Use a Free Gold EA?
A free EA offers a low-risk way to experiment with algorithmic trading. Whether you’re a beginner looking to learn, or a seasoned trader testing new ideas, using a free Gold EA gives you:
✅ Automated execution — Trades are placed based on logic, not emotion
✅ Time savings — No need to monitor charts all day
✅ Backtestability — Test strategies on historical XAU/USD data
✅ Scalability — Use on multiple accounts or brokers
✅ Risk control — Many EAs come with built-in stop loss and money management settings
🛑 Important: Not all free EAs are created equal. Many publicly available versions are oversimplified or outdated, while others are optimized only for historical performance and may fail in live markets.
Key Features to Look for in a Free Gold EA
When selecting a free EA to use on MT4 for XAU/USD, ensure it has the following features:
- Stable performance across different market conditions
- Adjustable risk parameters (lot size, SL/TP, max trades)
- News filter or time filter to avoid volatile periods if needed
- Trailing stop / breakeven logic for risk minimization
- Compatible with ECN/STP brokers
- No restrictions on broker types or trading styles
Recommended Use Cases
Small accounts: Test low-risk strategies with micro lots
Prop firm challenge: Automate part of your trading to meet consistency goals
Supplement manual trading: Let the EA handle trades while you focus on analysis
Testing grounds: Run on demo to learn how algorithmic trading behaves during NFP, CPI, or Fed decisions
Limitations of Free Gold EAs
While free EAs are a great starting point, be aware of their limitations:
- Limited optimization: Default settings may not suit your broker
- No support or updates: Most free versions don’t include ongoing development
- Broker sensitivity: Slippage and spread can affect profitability
- Generic logic: Some free EAs rely on simple indicators like moving averages or RSI without deeper analysis
How to Install a Free Gold EA on MT4
Download the EA (.ex4 or .mq4 file)
Open MT4 → File → Open Data Folder
Paste the file into the MQL4 → Experts folder
Restart MT4
Drag the EA onto a XAU/USD chart (preferably M5 or M15 timeframe)
Enable AutoTrading and adjust inputs as needed
Conclusion
A Free MT4 Gold EA is a fantastic way to enter the world of algorithmic gold trading without any upfront costs. Whether you’re seeking consistent passive trades or want to test your strategies before going live, automated trading with MT4 offers flexibility and control.
Just remember—free doesn’t mean risk-free. Always test on demo accounts, monitor performance, and consider upgrading to premium tools if you want advanced features like latency arbitrage, multi-account trade copying, or FIX API support.
📘 MT4 Free Gold EA – Frequently Asked Questions (FAQ)
❓ What is the MT4 Free Gold EA?
The MT4 Free Gold EA is an automated trading system (Expert Advisor) designed specifically for trading the XAU/USD pair (Gold vs. US Dollar) on the MetaTrader 4 platform. It includes multiple strategies such as trend-following, scalping, grid trading, news breakout, and a conceptual arbitrage module.
❓ Is this EA really free?
✅ Yes, 100% free to download and use. There are no license fees, subscriptions, or time limits. You can use it on demo or live accounts without restriction.
❓ Which trading strategies are included?
This EA combines 5 different logic modules:
- Trend Following (SMA Crossover) – Classic strategy for capturing long-term moves.
- Scalping During High Volatility – Short-term breakout trades based on Bollinger Bands.
- News-Based Breakout Trading – Straddle orders before scheduled news events.
- Grid / Hedging Strategy – Dual-direction trades with spacing and risk layering.
- Simplified Arbitrage Detector – Conceptual logic for price-feed-based arbitrage (requires external data feed).
❓ Can I choose which strategy to use?
In this version, all strategies are included as separate blocks in the .mq4
code. You can:
- Use only one at a time by commenting out the others
- Or ask us for a dropdown input to enable switching in real time
❓ On which timeframes does the EA work?
- Trend Following: Best on H1 or H4
- Scalping: Use on M1 or M5
- Grid: Any timeframe
- News Trading: Works on any, usually M5
- Arbitrage: Timeframe irrelevant (feed-driven)
❓ Can I run this EA on other pairs or just Gold?
This EA is optimized for XAU/USD, but the logic can be adapted to other volatile instruments. For accuracy, we recommend sticking to gold unless you’re an experienced coder.
❓ What broker should I use?
Use brokers with:
- Low spreads on XAU/USD
- No execution delay (ECN/STP recommended)
- No restrictions on EAs or hedging
- Fast order execution (ideally <100ms)
❓ Does it use Stop Loss / Take Profit?
Some strategies include fixed SL/TP or trailing logic. You can add your own SL/TP levels by modifying the OrderSend
functions or let us add inputs for them.
❓ Is it safe to use on a live account?
Like any EA, you must test it first on a demo account. While it’s designed for stability and includes risk controls, live trading carries real risk.
❓ Can I modify the code?
Absolutely. The EA is open source. You can:
- Change indicators or parameters
- Add custom filters
- Integrate with other systems (e.g., trade copier, signal service)
❓ Can I use it with prop firms?
Some prop firms allow EAs, but others prohibit certain trading behaviors like grid, arbitrage, or news straddling. Always check the firm’s rules before using this EA in an evaluation.
❓ Does it require any special setup?
For most strategies:
- Just attach to a chart and enable AutoTrading
- For news trading, you’ll need to set the exact time of the release
- For arbitrage, external feed connection is needed (not included)