# What Is an Expert Advisor and How Does It Sync Trades

> Expert Advisors do more than automate trading. They can also sync your trade data to external tools like journals. Here is exactly how that works.

**Tags:** expert-advisor, ea, mt4, mt5, trade-sync
**URL:** https://traderjournal.app/metatrader/what-is-an-expert-advisor-trade-sync

---


# What Is an Expert Advisor and How Does It Sync Trades

Expert Advisors (EAs) are one of MetaTrader's most powerful features. Most traders associate them with automated trading strategies - bots that place and manage trades without human input. But EAs can also serve a different purpose: reading account data and pushing it to external services.

Understanding how this works helps you set up your journal sync correctly and troubleshoot if something goes wrong.

---

## What an Expert Advisor Actually Is

An EA is a program written in MetaQuotes Language (MQL4 for MT4, MQL5 for MT5) that runs inside your trading terminal. It has access to:

- Market data (prices, indicators, chart information)
- Account information (balance, equity, positions, history)
- Order management functions (open, modify, close positions)
- Network functions (send HTTP requests to external URLs)

Strategy EAs use the order management functions to trade automatically. Data-sync EAs use the account information and network functions to push data to an external endpoint. They do not trade.

---

## How a Trade-Sync EA Works Step by Step

Here is what happens inside the Trader Journal EA during a normal 30-second sync cycle:

**1. Check the timestamp**
The EA reads a value from MT4's GlobalVariables storage - a shared memory area that persists between EA restarts. This value is the timestamp of the last successful sync.

**2. Query closed trades since the last sync**
Using MQL4's OrdersHistoryTotal() and OrderSelect() functions (or HistoryDealsTotal() in MT5), the EA reads all closed trades with a close time newer than the stored timestamp.

**3. Build the JSON payload**
For each new closed trade, the EA builds a JSON string manually with all the relevant fields: ticket, symbol, type, open/close time, open/close price, lots, profit, commission, swap.

**4. Send via WebRequest**
The EA calls MT4's WebRequest() function, sending the JSON payload to the Trader Journal API endpoint via HTTPS POST. The server receives it, authenticates via the API key in the header, processes the trade data, and stores it.

**5. Update the timestamp**
After a successful push, the EA updates the GlobalVariable timestamp to the most recent close time. The next sync cycle will only look for trades newer than this.

**6. Push open positions and equity**
The same cycle also queries currently open positions and the account's current balance and equity, sending those as separate requests.

---

## Why WebRequest Needs to Be Enabled

MetaTrader 4 and 5 block external network requests from EAs by default. This is a security measure to prevent malicious EAs from sending your data to unknown servers or making unauthorized requests.

To allow the Trader Journal EA to make its sync requests, you explicitly whitelist the Trader Journal API domain in MT4/MT5's settings. This tells the terminal: "I authorize this URL to receive HTTP requests from EAs on this installation."

Without this step, the EA runs but all sync attempts fail silently (or with an error in the Experts log).

---

## Can an EA Access My Funds or Place Trades?

The Trader Journal EA is a read-only data collector. It uses account info functions to read data. It does not call any order management functions - not OrderSend(), not OrderClose(), not OrderModify(). It cannot place, modify, or close any trade.

Even if you shared your API key with someone else, they could not use it to access your funds. The API key authenticates data pushes from the EA to the journal server. It has no relationship to your broker login credentials.

---

Download Trader Journal and get the EA at android.traderjournal.app or ios.traderjournal.app.