MT4 Expert Advisor for Gold: How an EA Runs Inside MetaTrader

Quick Answer

An Expert Advisor for MT4 is a compiled .ex4 file (.ex5 on MT5) that sits in the platform's Experts folder, is attached to one chart such as XAUUSD, and runs its code each time a new price tick arrives for that chart's symbol. It can place trades only while the terminal is open and connected, the toolbar's AutoTrading switch (Algo Trading in MT5) is on and the EA itself is allowed to trade, and what it does is recorded in the Experts tab at the bottom of the terminal. A gold EA does this on the XAUUSD chart: it does not predict the market, it applies its coded rules to every new price. Golden Viper EA is MT5-only.

Shop around for a gold trading robot for more than a few minutes and you will notice the terminology gets thrown around loosely. "EA," "bot," "signal," and "algo" all get used almost interchangeably, and vendor marketing rarely explains what is actually happening under the hood. This guide breaks down what an Expert Advisor really is, how one turns a gold chart into a trade, what separates a well-built system from a risky one, and how to verify a track record before you commit real money. Along the way, a few numeric examples make the mechanics concrete rather than abstract.

Try Golden Viper EA free for 3 days A gold grid EA for MT5 cent accounts, with a live account you can check on Myfxbook. Start with a free trial key, then choose 1 month for $49, 1 year for $199 or lifetime for $299.
Start Free 3-Day Trial →

What an Expert Advisor Actually Is

An Expert Advisor is a piece of software written for the MetaTrader platform, in MQL4 for MetaTrader 4 or MQL5 for MetaTrader 5, that plugs directly into your trading terminal. Once attached to a chart, it runs continuously in the background, reading live price data on every tick or on every new candle close, depending on how it was built. The MQL programming documentation defines the exact functions a developer can use: reading price history, placing orders, modifying stops, and managing open positions, all inside a sandboxed environment that the broker's server ultimately executes against.

The key distinction to understand is that an EA is not "AI" in the generative sense, and it is not a black box that learns and rewrites its own rules on the fly. Think of it more like a very disciplined checklist. A developer defines what conditions must be true before a trade opens, how big the position should be relative to your account, where the trade closes for a loss, and how (if at all) the trade should be managed while it is open. The EA then applies that identical checklist every single time, at any hour, without fatigue, without hesitation, and without the emotional swings that cause many discretionary traders to abandon a good plan mid-trade.

EA, Signal Copier, and Indicator: Not the Same Thing

People frequently conflate three different tools. An indicator (like a moving average) only draws information on the chart; it never places a trade by itself. A signal service, such as those listed on the MQL5 Signals marketplace, copies another trader's or system's positions into your account in near real time, but the decision-making happens elsewhere. An EA, by contrast, makes the decision and executes it locally, inside your own terminal, using your own account settings. Golden Viper EA is the third kind: it runs directly on your own MT5 terminal, making and executing its decisions locally, and you buy a license key for it (a one-time $299 lifetime key, or a 1-month or 1-year key) rather than subscribing to someone else's signal.

Where Each Part of an EA Lives in MetaTrader

For the general idea, see what an expert advisor is; this table shows where each piece sits inside the platform.

PartMetaTrader 4MetaTrader 5
File you installCompiled .ex4 (source code is .mq4)Compiled .ex5 (source code is .mq5)
FolderFile > Open Data Folder > MQL4 > ExpertsFile > Open Data Folder > MQL5 > Experts
How you start itDrag it from Navigator > Expert Advisors onto the chartThe same, or double-click it in the Navigator
When its code runsOn each new tick of the chart's symbolOn each new tick; a tick that arrives while the last one is still being processed does not queue a second run
Master switchAutoTrading button on the toolbarAlgo Trading button on the toolbar
Per-EA permission"Allow live trading" in the EA's propertiesTrading permission in the Common tab of the EA's properties
Its messagesExperts tabExperts tab of the Toolbox

MetaTrader 5's help states that only one Expert Advisor can run on one chart, so a second EA dropped on the same chart replaces the first. For Golden Viper EA (MT5 only), copy the .ex5 into MQL5 > Experts, add https://goldenviperea.com under Tools > Options > Expert Advisors, "Allow WebRequest for listed URL" (off by default; the EA checks its license online), attach it to one XAUUSD chart on a hedging account and paste the key into its only input, "License key". It writes nothing of its own to the Experts tab except license and setup alerts, so a quiet log is normal. If it never opens a basket, work through why an MT5 EA is not taking trades.

How an EA Trades Gold (XAUUSD) Step by Step

Gold trades under the symbol XAUUSD on most brokers, quoted in US dollars per troy ounce, and it behaves differently from a typical currency pair. It reacts to real interest rates, the US dollar, and safe-haven demand as much as to pure technical levels, a dynamic covered in more depth in our piece on how central bank policy moves the gold price. A gold EA has to be built with that character in mind rather than simply repurposing a strategy designed for EUR/USD. Here is the general sequence a rules-based XAUUSD EA follows on every new candle:

  1. Data collection: the EA reads the most recent price bars for XAUUSD on its assigned timeframe (commonly H1, H4, or Daily for gold, since lower timeframes tend to produce excessive noise around a metal this volatile).
  2. Condition check: it evaluates its coded rules, typically a blend of trend direction and momentum confirmation, against the current price structure. If the conditions are not met, the EA does nothing and waits for the next candle.
  3. Trade sizing: once a valid setup appears, the EA calculates position size based on your account balance and a chosen risk percentage, rather than using a fixed lot size for every trader regardless of account size.
  4. Order placement: the EA sends a market or pending order to the broker, along with a protective stop level.
  5. Trade management: while the position is open, the EA may adjust the stop, lock in partial profit, or leave the trade to run to its target, depending on how it was designed.
  6. Exit and logging: the trade closes on a stop, a target, or a rule-based exit signal, and the result is recorded to your account history and, if connected, to a public verification service.

Why H4 Is a Common Choice for Gold EAs

Gold can move $15 to $30 in a matter of minutes around major US data releases, which makes very short timeframes prone to whipsaws for a fully automated system. Some XAUUSD EAs are built around the H4 (4-hour) chart and are deliberately selective, aiming for roughly one qualifying setup per day at most rather than dozens of trades, which is a design choice favoring fewer entries over chasing every minor fluctuation. Others work differently: Golden Viper EA is a grid system that keeps adding averaging-down levels as price moves against it, and it chooses the direction once, when a basket starts, so the chart timeframe does not matter. For EAs that run in the Strategy Tester (Golden Viper EA does not), you can see how this plays out historically by running your own MT5 backtest against several years of XAUUSD data before ever trading it live.

Inside a Gold EA: The Core Building Blocks

Every credible EA, regardless of the specific strategy it runs, is assembled from the same functional components. Understanding these helps you evaluate any product on the market, not just by its marketing claims but by whether the underlying architecture actually makes sense.

ComponentWhat It DoesWhy It Matters to You
Entry logicRules that decide when a trade or a new basket is valid, for example a trend filter such as a moving averageDetermines trade frequency and how selective the system is
Position sizingCalculates lot size: from account equity and a risk percentage, from a fixed lot, or from a lot ladder that grows per levelDecides how much risk each trade or grid level adds as your balance grows or shrinks
Stop-loss / protective stopDefines the maximum the EA will lose, either per trade or as a floating-loss limit on the whole account or basket (some grid EAs have no stop-loss at all)Caps downside when it is used, so check whether it is switched on, a core piece of sound risk management
Take-profit / trade managementCloses or adjusts the position once it moves favorably, per trade or for a whole basketDecides when gains are banked and how long losing positions stay open
Magic number / order taggingA unique ID attached to every order the EA placesLets the EA track its own trades separately from manual ones, even when several systems share one account
Risk limitsInputs such as a maximum number of open trades, a lot size, or a drawdown limit, depending on the EALets you match the EA's behavior to your own risk tolerance

Notice what is deliberately absent from that list: there is no "predictive AI module" and no proprietary indicator name worth memorizing. A transparent vendor will tell you the strategy category, for Golden Viper EA that is an averaging-down gold grid applied only to XAUUSD, with direction chosen by a built-in trend filter when a basket starts, without pretending a specific indicator combination is a secret formula that guarantees results. Be skeptical of any product that claims otherwise, and treat that skepticism as sound practice under standard risk-management principles.

Anatomy of a Single XAUUSD Trade, Start to Finish

Numbers make this concrete. Say you are running a hypothetical stop-loss-based EA (not Golden Viper EA, which has no stop loss) on a $5,000 account, set to risk roughly 1% of equity per trade, and gold (XAUUSD) is trading at $2,350.00.

On the H4 close, the EA's trend and momentum conditions align and it opens a long position. Based on current volatility, it sets a stop-loss $12.00 below entry, at $2,338.00. With 1% risk on a $5,000 account, the EA is willing to lose $50 if the stop is hit. Because each 0.01 lot (a micro lot) of XAUUSD typically moves roughly $1.00 in value per $1.00 price change on most broker contract specifications, a $12.00 stop distance on a 0.04-lot position would risk approximately $48, close enough to the 1% target that the EA sizes the trade at 0.04 lots.

Gold rallies over the following 14 hours to $2,368.00. Rather than waiting passively for a single fixed target, the EA's profit-lock mechanism moves the effective exit point up as price advances, protecting a growing share of the open gain. Price eventually pulls back and the trade closes with a locked-in gain around $2,364.00, for a net profit of roughly $56 on the $5,000 account, about 1.1%. That single trade shows the loop in action: fixed risk in dollar terms, a mechanical stop, and a management rule that tries to protect profit once the trade is working, all without a single manual decision from you. Small disciplined edges like this, compounded across many trades and long stretches of time, are the basis for the kind of realistic earnings a well-run gold EA can produce over a full year rather than a single lucky week.

MT4 vs. MT5: Does the Platform Change How the EA Trades?

Both MetaTrader 4 and MetaTrader 5 support automated trading through Expert Advisors, but there are real differences worth knowing before you pick a platform, or ideally before you pick an EA license that covers both.

FeatureMetaTrader 4 (MT4)MetaTrader 5 (MT5)
Programming languageMQL4MQL5 (more modern, object-oriented)
Order execution modelSeveral open orders on one symbol (MT5's hedging mode works in a similar way)Supports netting and hedging depending on broker
Backtesting engineSingle-threaded strategy testerMulti-threaded, generally faster for large data sets
Broker availability for gold (XAUUSD)Very widely offeredWidely offered, increasingly the default for new accounts
Typical EA compatibilityMQL4-coded EAs onlyMQL5-coded EAs only (unless a dual build is provided)

The practical takeaway: an EA compiled for MT4 will not run natively on MT5 and vice versa, because the underlying code languages differ. That is why it matters whether a vendor gives you one license that actually covers both platform versions, rather than forcing you to buy twice if you ever switch brokers or platforms. Golden Viper EA, for example, is MT5-only: it ships as one compiled .ex5 file under one license key, with no MT4 build. If you are unsure which platform suits your broker of choice, it is worth comparing execution conditions between brokers commonly used for gold EA trading before you commit.

Risk Management: The Part That Actually Determines Survival

The single biggest misconception new EA users have is that automation removes risk. It does not; it removes emotion from execution, but the underlying market risk on every gold trade is exactly the same as if you placed it manually. Drawdown, the peak-to-trough decline in your account balance during a losing stretch, is unavoidable in any strategy that takes real market risk, and understanding it before you start is essential. Our dedicated guide on how drawdown works walks through the math in detail.

A well-built gold EA is clear about how you control the risk you are exposed to:

  • Stated position sizing. Some EAs size each position as a percentage of your current balance, so a $2,000 account and a $20,000 account each risk a proportional amount. Others use a fixed lot ladder designed for a stated account balance. Either way, the vendor should tell you which one it is.
  • A clear risk lever. Some EAs expose inputs such as a start lot, a level cap or an equity stop. Others, like Golden Viper EA, keep every trading setting fixed (the only input is the license key), so your lever is the size of the account you run it on.
  • Honest disclosure of martingale or grid averaging. Some automated systems attempt to recover losses by doubling down or adding to a losing position. This approach can produce a smooth-looking equity curve right up until it produces a catastrophic one. A transparent vendor says plainly whether its EA does this (Golden Viper EA is an averaging-down grid, without doubling), so you can size your account for it.

Whatever system you run, protecting your capital has to come first, and understanding drawdown fully before you fund a live account is worth more than any single feature comparison between products.

Verifying a Track Record Before You Trust It

Anyone can screenshot a MetaTrader terminal showing a green equity curve. That is exactly why independent verification matters, and why US regulators specifically warn traders to scrutinize performance claims. The CFTC's advisory on trading system fraud flags unverifiable or self-reported results as a recurring red flag in automated trading offers.

Myfxbook is the industry-standard third-party verification tool. It connects directly to a live broker account via read-only investor credentials and publishes the real, unedited trade history, so you cannot selectively hide losing trades once an account is linked. The platform's own verification process confirms the account is actually funded and traded, not a demo or a curated export. Before trusting any gold EA's performance claims, take these steps:

Verification StepWhat to CheckRed Flag if Missing
Third-party account linkA public, verified Myfxbook or MQL5 signal page tied to a real broker accountOnly in-house screenshots or PDF reports
Account history lengthMonths to years of continuous, unedited trade dataOnly a few weeks of hand-picked results
Drawdown disclosureMaximum drawdown is clearly published, not hiddenOnly profit figures are shown; drawdown is never mentioned
Guarantee languageHonest risk disclosure; no "guaranteed" or "risk-free" claimsPromises of guaranteed profit or no-risk trading, which the CFTC explicitly warns against
Platform compatibility proofThe EA is shown running live on the actual MT5 build you would receiveVague claims with no way to confirm which version was tested

If you plan to run your own account and want an outside record of your results, connecting your terminal to a verification service is straightforward. Our walkthrough on linking MT5 to Myfxbook covers the setup end to end.

What It Actually Costs to Run a Gold EA

Beyond the EA's purchase price, there are a handful of recurring costs that determine your real net return, and skipping this math is one of the most common mistakes new users make.

  • License cost: a one-time or subscription fee for the EA itself. Golden Viper EA, for instance, is sold as a license key for the MT5 build (there is no MT4 version): a one-time $299 lifetime license, or a $199 1-year or $49 1-month license, each paid once or set to autopay, which you can cancel, plus a free 3-day trial key (one per email and per MT5 account). You run the EA file on your own terminal; there is no separate signal or subscription option.
  • Broker spread and commission: gold spreads vary meaningfully between brokers, and a wide spread quietly erodes returns on every single trade. Compare providers using our guide to gold broker spreads before opening an account.
  • VPS hosting: because an EA needs the terminal running continuously to catch every H4 candle close, most users run a low-cost virtual private server (typically $5 to $15 per month) rather than leaving a home PC on 24/7, since a dropped connection can leave an open position unmanaged.
  • Starting capital: undercapitalizing an account forces oversized position risk relative to account swings, so sizing your starting balance sensibly matters as much as choosing the EA itself.

None of these costs are hidden if a vendor is being straightforward with you, but they are easy to overlook when comparing sticker prices between products.

Common Mistakes First-Time EA Users Make

Even a well-built EA can produce a poor experience if it is set up carelessly. The most frequent errors are rarely about the strategy itself:

  • Skipping the settings review. Running an EA on default settings without understanding what each input controls is a common early mistake; our guide to EA settings explains what the common parameters actually do before you go live.
  • Ignoring VPS uptime. If your terminal disconnects mid-trade, an open position can sit unmanaged. A stable VPS avoids this entirely.
  • Running multiple EAs on one account without magic numbers. Without unique order tagging, systems can interfere with each other's trade management.
  • Expecting daily action. A selective, H4-based gold EA that trades roughly once a day at most is working correctly even during quiet weeks. The absence of trades is not a malfunction.
  • Chasing unverifiable performance claims. Revisit the verification checklist above before funding any account based on marketing screenshots alone.

Is an EA Right for You? Automated vs. Manual Gold Trading

Manual XAUUSD trading demands screen time, fast decision-making around volatile news windows, and a level of emotional discipline that even experienced traders struggle to maintain consistently, a challenge covered in our piece on how economic news moves gold prices. An EA removes hesitation and emotional overrides from execution, applying the exact same rules on trade 500 as it did on trade 1. That consistency is valuable, but it is not a substitute for understanding what you are running. You should still know your maximum acceptable drawdown, your position-sizing logic, and your platform mechanics well enough to recognize normal behavior versus a genuine problem once you are live. For a broader look at whether automation suits your goals at all, see is automated gold trading actually profitable, which weighs the honest tradeoffs rather than overselling the concept.

You can learn more about how Golden Viper EA specifically is built and verified on the Golden Viper EA homepage, including links to its public, independently verified track record.

A Short, Honest Risk Disclosure

Trading gold, manually or through an Expert Advisor, carries real risk, and losses are possible, including on strategies with a long history of prior wins. Past performance, whether from a backtest or a live verified account, does not guarantee future results. Gold prices are influenced by macroeconomic factors, including central bank policy and interest-rate expectations tracked by resources like the World Gold Council, and no automated system can eliminate that underlying market uncertainty. Only trade with capital you can actually afford to lose, and treat any product promising guaranteed returns as a warning sign rather than an opportunity.

Frequently Asked Questions

Where can I see what my EA is doing in MT4 or MT5?

Open the Experts tab at the bottom of the terminal: it shows the EA's own messages, such as when it loaded, errors and any alerts it writes. The Journal tab next to it shows platform events. If the EA shows nothing at all, check that AutoTrading (Algo Trading in MT5) is on and that the EA is allowed to trade in its properties.

What is the difference between an .ex4 and an .mq4 file?

An .mq4 file is the EA's source code; an .ex4 file is the compiled program that MetaTrader 4 actually runs (in MT5 the pair is .mq5 and .ex5). Commercial EAs are usually delivered as compiled files only, so the source code stays with the developer; Golden Viper EA, for example, is supplied only as a compiled .ex5 file.

What exactly is an Expert Advisor in MT4?

It is an automated trading program coded in MQL4 that attaches to a chart inside MetaTrader 4 and executes trades based on a fixed set of rules, without requiring you to manually click buy or sell.

Do I need coding experience to use an EA?

No. Commercial EAs, including gold-focused ones, are delivered as ready-to-run files that you attach to a chart and configure through simple input settings. No programming knowledge is required to operate one.

Can an EA guarantee profitable gold trades?

No legitimate EA can guarantee profits. Trading always carries risk, and any product claiming guaranteed or risk-free returns should be treated as a red flag consistent with warnings from the CFTC and FTC.

Why do some EAs only trade gold and not other pairs?

Gold has distinct volatility and behavior compared to currency pairs, reacting strongly to interest rates and safe-haven flows. A strategy specifically built and tuned around XAUUSD's characteristics can be more consistent than a generic multi-symbol system.

What timeframe do gold EAs typically trade on?

Many serious XAUUSD systems use the H4 (4-hour) chart, which filters out short-term noise while still capturing meaningful intraday moves. Some EAs also use H1 or Daily timeframes depending on their design.

How is position size decided by an EA?

Most modern EAs use risk-based lot sizing, calculating position size as a percentage of your current account balance and the distance to the stop-loss, rather than a fixed lot size for every account.

Is an EA the same as an MQL5 signal subscription?

No. An EA runs the strategy locally in your own terminal using your own settings. A signal subscription copies trades from another source into your account in near real time; the decision logic runs elsewhere.

How can I verify an EA's performance claims are real?

Look for a public, independently verified account on a service like Myfxbook or an MQL5 signal page linked directly to a live broker account, with continuous unedited history and disclosed drawdown, rather than isolated screenshots.

Does an EA need to run on a VPS?

It does not strictly require one, but because most EAs need the terminal open continuously to catch each new candle, a stable VPS is the practical standard so trades are not missed due to a closed laptop or lost internet connection.

Will the same EA work on both MT4 and MT5?

Only if the vendor provides separate builds compiled for each platform, since MT4 uses MQL4 and MT5 uses MQL5, which are not interchangeable. Check whether a single license covers both builds before purchasing.

Myfxbook Verified

Automate Your XAUUSD Trading

MT5Hedging cent account
XAUUSDGold only
GridBasket take-profit
Lifetime license $299 one-time
Get Lifetime Access — $299 →
✓ License key by email✓ One MT5 account per key✓ MT5 cent accounts✓ Full setup help
GV

Golden Viper EA

Written by Golden Viper EA, the maker of the Golden Viper EA gold Expert Advisor for MetaTrader 5. We sell the EA, so weigh our product mentions with that in mind; its live account is public on Myfxbook.

Myfxbook VerifiedLive account verified on MyfxbookPublic track record

Let Golden Viper EA trade gold for you

Automated XAUUSD grid trading for MT5 cent accounts, verified live on Myfxbook. One-time $299, lifetime access.

Get Lifetime Access — $299

Start Free 3-Day Trial → · Full setup help