> For the complete documentation index, see [llms.txt](https://docs.metacopier.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.metacopier.io/features/custom-ea-hosting.md).

# EA hosting

<figure><img src="https://1880479925-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYatpTySDvBNuxKqpErzU%2Fuploads%2FudZrxU9o8Ac5BAeVEcvB%2Fhow-it-works.svg?alt=media&amp;token=38503cc1-52b2-4fa2-910f-f8787dfd3d23" alt=""><figcaption></figcaption></figure>

With **EA hosting** you can run your own expert advisors (EAs) on MetaTrader 4 and MetaTrader 5 accounts connected to MetaCopier. You upload the compiled expert once, pick the account, symbol and timeframe, and MetaCopier keeps the expert running 24/7. There is no VPS to rent and no terminal to maintain.

Every hosted expert runs in its **own MetaTrader terminal**, separate from the one MetaCopier uses for copying. If an expert crashes or hangs, your copiers keep working.

EA hosting only runs experts on your connected accounts. MetaCopier does **not** offer backtesting or forward testing of experts.

{% hint style="warning" %}
EA hosting is currently in **beta**. Behaviour and limits may still change, and occasional issues are possible. Please report any problems to support.
{% endhint %}

## Requirements

* The account is a **MetaTrader 4** or **MetaTrader 5** account. Other platforms are not supported.
* The account is **active**.
* You have the **compiled** expert file: `.ex5` for MT5 or `.ex4` for MT4. Source files (`.mq5` / `.mq4`) cannot be run.
* Experts bought or rented on the **MQL5 Market** are **not supported**. MetaTrader binds an activated Market product to the computer it was activated on, and it only starts when your MQL5 account is logged in to the terminal, so it cannot run on a hosted terminal. Use an expert you received as a standalone `.ex5` / `.ex4` file instead.
* Experts that check their **licence online** with their vendor need the vendor's licence server under [**WebRequest URLs**](#settings). This is only possible on **MT5**.

## How It Works

Before you start, connect the MetaTrader account the expert should trade on to your project and make sure it is **active**. See [Connect your accounts](/tutorials/quick-start-guide.md#connect-your-accounts).

{% hint style="info" %}
For EA hosting you only need to add **one account**: the account the expert trades on. You do **not** need a second account and you do **not** need to set up a copier.
{% endhint %}

### Step 1: Get the files from MetaTrader

1. Open MetaTrader and click **File** → **Open Data Folder**.
2. Go to `MQL5/Experts` (MT5) or `MQL4/Experts` (MT4) and find the compiled expert, the file ending in `.ex5` or `.ex4`. If you only have the `.mq5` / `.mq4` source, open it in MetaEditor and click **Compile** first.
3. If the expert uses custom indicators or libraries, take their `.ex5` / `.ex4` files from the `Indicators` and `Libraries` folders as well.
4. Optional: to run the expert with your own input values, attach it to a chart, open the **Inputs** tab, click **Save** and store the `.set` file. Without a preset, the expert runs with its compiled default inputs.

### Step 2: Upload the files

1. Open your project and click **Files** in the project navigation.
2. In the **Experts** group, click the upload button of your platform (**EA\_MT5** for MT5, **EA\_MT4** for MT4) and select the expert. You can also drag the file onto the group.
3. Upload indicators, libraries, the preset and data files the same way in the **Indicators**, **Libraries**, **Presets** and **Data** groups.
4. Each file now appears in its group with its version and size.

{% hint style="info" %}
Upload the file that matches the account platform. An `.ex4` cannot run on an MT5 account and vice versa.
{% endhint %}

### Step 3: Add the feature to the account

1. Open **Accounts** in the project navigation.
2. On the card of the MetaTrader account, click **Features**.
3. Click the **+** button. The **Add feature** dialog opens.
4. Search for **Custom EA hosting** and select it. The feature is only listed for MT4 and MT5 accounts.

### Step 4: Configure the expert

Fill in the **Custom EA hosting** dialog:

1. **Expert advisor (.ex5 or .ex4):** Select the expert you uploaded. If the list is empty, the file was not uploaded or was uploaded for the other platform. Go back to step 2.
2. **Symbol:** Select the chart symbol exactly as your broker names it, including any suffix (e.g. `EURUSD.pro`).
3. **Timeframe:** Select the chart timeframe the expert is meant for. The default is **H1**.
4. **Inputs preset (.set):** Select your preset, or leave it empty to use the default inputs.
5. **Companion files:** Add every indicator, library and data file the expert loads. Skip this if the expert needs none.
6. **WebRequest URLs (MT5 only):** Add the servers the expert calls, for example the licence server of the vendor. Leave it empty if the expert does not call out.
7. Leave **Running**, **Live trading** and **Experts enabled** switched on. To test the expert without placing real orders, switch **Live trading** off.

All options are explained under [Settings](#settings).

### Step 5: Save

Click the save button at the bottom of the dialog.

MetaCopier now transfers the files, starts a dedicated terminal, logs in to your broker and attaches the expert to the chart. This usually takes a minute or two.

### Step 6: Check that the expert is running

1. On the account card, a chip **EA: \<expert name>** appears. Its colour shows the state, and hovering it shows the state as text. The state changes from **Starting** to **Running** as soon as the terminal confirms that the expert is loaded on the chart. The **Expert Advisors** overview on the Accounts page lists all hosted experts of the project.
2. Click the chip to open **Status and logs**. **Broker** should show **Connected** and **Expert** should show **Loaded**.
3. Switch the log source to **Expert** and check the messages your expert prints on start. Errors from `OnInit`, missing files or rejected orders show up here.
4. If the state is **Error**, the reason is shown above the logs. See [Troubleshooting](#troubleshooting).

From then on, MetaCopier checks the expert continuously and restarts it automatically if it stops unexpectedly (see [Automatic restarts](#automatic-restarts)).

### Update the expert later

1. Upload the new build on the **Files** page with the **same file name**. It is stored as a new version, and the running expert is not affected yet.
2. Open **Features** on the account and edit the **Custom EA hosting** feature.
3. Select the new version (marked **latest**) under **Expert advisor** and click **Save**.

The terminal restarts with the new version. Open positions stay open during the restart.

The expert trades on your account like it would on your own terminal. Trades it opens are normal account positions, so they appear in MetaCopier and can be copied to other accounts like any other trade.

## Files

The **Files** page of a project stores everything your experts need. A file uploaded there can be attached to an EA hosting deployment on any MetaTrader account of the project. You can upload a file with the upload button of its group or by dragging it onto the group.

| Group      | Extension               | Max size | Purpose                                         |
| ---------- | ----------------------- | -------- | ----------------------------------------------- |
| Experts    | `.ex5` / `.ex4`         | 8 MB     | The compiled robot a deployment runs            |
| Indicators | `.ex5` / `.ex4`         | 8 MB     | Custom indicators the expert calls              |
| Libraries  | `.ex5` / `.ex4`         | 8 MB     | Shared code the expert imports at runtime       |
| Presets    | `.set`                  | 64 KB    | Input sets you can pick per deployment          |
| Data       | `.csv`, `.txt`, `.json` | 4 MB     | Files the expert reads from the terminal folder |
| DLL        | `.dll`                  | 16 MB    | Native libraries, only after a staff review     |

* **Storage:** Each project has **100 MB** of storage. The storage bar at the top of the page shows how much is used. Switch on **Unused only** to see which files no deployment references any more.
* **Versions:** Uploading a file with the same name but different content creates a **new version**. The old version is kept, so running deployments are not affected. Uploading identical content again does not create a new version. A file name can have up to **20 versions**.
* **Delete:** A file version that a deployment still uses cannot be deleted. Remove it from the deployment first. Under **Used by**, each file shows the account and the deployment that use it.
* **Reserved names:** File names starting with `mc_` and a few internal names are reserved and cannot be uploaded.
* **Presets and data files** must be text. Upload presets exactly as MetaTrader saved them: MT5 saves them as UTF-16 and MT4 as ANSI, and both are accepted, as is UTF-8.

{% hint style="info" %}
Deleting an EA hosting deployment never deletes its files. Uploaded files cost nothing.
{% endhint %}

### DLLs

DLL import is **switched off** on hosted terminals. An expert that needs a DLL can only be deployed after a **source review** by our staff. Both the expert and every DLL it loads must pass the review. The review can take **up to 2 weeks**. Contact support if your expert needs DLL access.

On the Files page, a reviewed DLL is marked as **Source reviewed by staff**. A DLL that is still awaiting review cannot be attached to an expert and is shown as **Not reviewed** in the feature dialog. Uploading a new version of a DLL requires a new review.

The DLL must match the platform: **64-bit** for MT5, **32-bit** for MT4.

## Settings

* **Expert advisor:** The compiled expert to run. Only files matching the account platform are listed, because an `.ex4` cannot load on MT5 and vice versa. Each entry shows the version, and the newest version of a file is marked **latest**. The deployment stays on the selected version, even if you upload a newer one later. To update the expert, upload the new version and select it here.
* **Symbol:** The chart symbol the expert runs on, exactly as your broker names it (e.g. `EURUSD`, `EURUSD.pro`). In a template, the symbol is entered manually.
* **Timeframe:** The chart timeframe.
  * **MT5:** M1, M2, M3, M4, M5, M6, M10, M12, M15, M20, M30, H1, H2, H3, H4, H6, H8, H12, D1, W1, MN1
  * **MT4:** M1, M5, M15, M30, H1, H4, D1, W1, MN1
* **Inputs preset (.set):** The input parameters of the expert. Create the file in MetaTrader with **Save** in the expert's **Inputs** dialog and upload it on the Files page. Without a preset, the expert runs with its compiled default inputs.
* **Companion files:** Indicators, libraries and data files the expert loads at runtime. Upload them on the Files page first, then add them here. MetaCopier places each file in the matching MetaTrader folder (`Indicators`, `Libraries` or `Files`). A preset is not a companion file; pick it under **Inputs preset** instead. Up to **20** companion files are allowed, and all files of a deployment together, including the expert, may not exceed **32 MB**.
* **Live trading:** If switched off, the terminal rejects all orders of the expert. Use this for a dry run.
* **Running:** Switch off to stop the expert and its terminal without deleting the deployment. It stays stopped until you switch it on again. The daily charge continues while the deployment exists.
* **Experts enabled:** The terminal's master switch for experts. If switched off, the expert does not run.
* **WebRequest URLs (MT5 only):** The servers the expert may call with `WebRequest()`. Enter an address and press **Enter** or **+** to add it, or paste several addresses at once. Remove an address with its trash icon. MetaTrader refuses calls to any address that is not listed. Leave the list empty if the expert does not call out.
  * Enter the server address only, for example `https://api.example.com`. If the server uses port **8443** or **9443**, add the port, for example `https://api.example.com:9443`. Paths, query strings and other ports are not allowed.
  * Only **HTTPS** is supported. Private, local and loopback addresses are refused.
  * Up to **64** addresses.
  * **Licensed experts:** If your expert checks its licence online with its vendor, add the vendor's licence server here. Ask the vendor which address the expert uses. Without it, the licence check fails and the expert usually refuses to trade. Do not switch on **Start without WebRequest URLs if they cannot be set up** for such an expert.
  * **MT4:** Not supported. An MT4 expert that calls `WebRequest()` cannot reach the internet on a hosted terminal.
  * **Start without WebRequest URLs if they cannot be set up:** Off by default. If the URLs cannot be set up when the terminal starts, the expert stays stopped with an error and is retried automatically. Switch this on if your expert works without `WebRequest()`, for example when it only uses it for logging. The expert then starts anyway, its `WebRequest()` calls fail until the next restart, and a warning is shown in its status.

{% hint style="info" %}
Every change to the settings restarts the expert's terminal so the new configuration takes effect. Positions stay open during the restart.
{% endhint %}

## Limits

* **Experts per account:** 5
* **Experts per project:** 25. Contact support if you need more.
* **Resources per terminal:** Every hosted terminal may use up to **40 % of one CPU core** (0.4 vCPU) and **400 MB memory**. CPU is measured as a share of one core, so 100 % means one full core. Windows Task Manager shows CPU as a share of all cores instead, so the same load appears much lower there. The status view warns you once an expert reaches half of the limit. An expert that stays above the limit is stopped with **Resource budget exceeded**. This usually points to an endless loop or to arrays and history data that keep growing.

## Status and logs

Open the EA hosting feature of an account and click **Status and logs**. You can also open it from the **Expert Advisors** overview on the Accounts page.

### States

| State        | Meaning                                                                    |
| ------------ | -------------------------------------------------------------------------- |
| **Starting** | The terminal is starting, logging in to the broker and loading the expert. |
| **Running**  | The terminal confirmed that the expert is loaded on the chart.             |
| **Error**    | The expert stopped. The reason is shown in the status view.                |
| **Stopped**  | The expert is not running.                                                 |

### Status

* **State:** The current state (see above).
* **Broker:** Whether the terminal is **Connected** to your broker.
* **Expert:** Whether the expert is **Loaded** on the chart.
* **Uptime:** How long the expert has been running since the last start.
* **CPU** and **Memory:** The current usage of the terminal, CPU as a share of one core, including a warning when it gets close to the limit.
* **Restarts:** How often the expert was restarted automatically.
* **Last lifesign:** When the terminal last reported.

If the expert is in an error state, the reason is shown in an alert above the logs.

### Logs

The log view shows the logs of the hosted terminal, just like the **Journal** and **Experts** tabs in your own MetaTrader.

* **Source:**
  * **Expert:** What the expert prints (`Print()`, `Alert()`, errors from `OnInit`, trade results and so on). This is the log you usually need to debug an expert.
  * **Terminal:** The terminal journal (broker connection, expert loading, trade requests).
  * **Both:** Both logs on one timeline.
* **Follow:** Automatically loads new lines every few seconds. Click **Pause** to stop following.
* **Reload:** Loads the latest lines again.
* **Download:** Downloads the full retained log history as a text file.

The log view only shows the most recent part of the history. Use **Download** for everything that is retained.

### Expert Advisors overview

If at least one expert is hosted in the project, the **Accounts** page shows an **Expert Advisors** panel. It lists every hosted expert with its state, account, expert name, symbol, timeframe, CPU and memory usage, the number of automatic restarts and the last error. The header shows how many experts are in each state. Click an expert to open its status and logs.

## Automatic restarts

If an expert stops unexpectedly, for example because the terminal lost its connection or the expert was removed from the chart, MetaCopier restarts it automatically. Repeated failures are retried with an increasing delay of **1, 2, 5 and then 15 minutes**.

The same applies to the broker connection: if the terminal is disconnected from your broker and does not reconnect by itself within **3 minutes**, the terminal is restarted. Meanwhile, the **Expert Advisors** overview on the Accounts page shows **Broker disconnected**.

Errors that a restart cannot fix are **not** retried, so the expert stays in the error state until you fix the cause:

* the expert file is not valid for the platform
* the expert needs DLL access
* the account credentials are wrong
* a companion file is missing
* the symbol does not exist at the broker
* the expert exceeded the resource limits

Fix the cause and save the feature again to restart the expert.

## Troubleshooting

| Message                                                                                | What to do                                                                                                                                                                                                  |
| -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| The terminal refused the expert advisor file.                                          | The file was compiled for the other MetaTrader version or is damaged. Upload the `.ex5` for MT5 or the `.ex4` for MT4.                                                                                      |
| The expert advisor is missing a file it needs.                                         | The expert calls a custom indicator, library or data file that is not attached. Check the **Expert** log for the file name, upload it and add it as a companion file.                                       |
| This expert advisor tries to load a DLL.                                               | DLL import is switched off. See [DLLs](#dlls).                                                                                                                                                              |
| The symbol is not valid.                                                               | Enter the symbol exactly as your broker names it, including any suffix.                                                                                                                                     |
| The terminal could not log in with these account credentials.                          | Check the login, password and server of the account.                                                                                                                                                        |
| The expert advisor used more CPU or memory than a hosted terminal is allowed to use.   | Check the expert for endless loops or data that keeps growing. See [Limits](#limits).                                                                                                                       |
| The expert advisor did not start within the expected time.                             | The terminal did not confirm the expert within 2 minutes. It is retried automatically. Check the **Terminal** log if it keeps happening.                                                                    |
| The hosting server stopped reporting for this expert advisor.                          | The expert is restarted automatically. No action is needed.                                                                                                                                                 |
| The terminal lost the connection to the broker and did not reconnect within 3 minutes. | The terminal is restarted automatically. If it keeps happening, check the **Terminal** log, check that the broker server of the account is still correct, and whether it is reachable or under maintenance. |
| No hosting capacity is free at the moment.                                             | Try again in a few minutes.                                                                                                                                                                                 |
| This file is still used by an expert advisor.                                          | A deployment still uses this file version. Remove it from the deployment, or select another version, before deleting it.                                                                                    |
| This file could not be read as text.                                                   | Upload the preset exactly as MetaTrader saved it, without opening and re-saving it in another editor. Otherwise save it as UTF-8 and upload it again.                                                       |
| The storage limit of this project is reached.                                          | Delete files you no longer need. Switch on **Unused only** on the Files page to find them.                                                                                                                  |
| This file already has the maximum number of versions.                                  | Delete an older version before uploading a new one.                                                                                                                                                         |
| This account already has the maximum number of hosted expert advisors.                 | Up to 5 experts per account are allowed. Delete one before adding another.                                                                                                                                  |

{% hint style="info" %}
If the expert loads but does not trade, check that **Live trading** and **Experts enabled** are switched on, and look at the **Expert** log for trade errors returned by the broker.
{% endhint %}
