
For serious traders managing multiple accounts, brokers, or platforms, a trade copier is a must-have tool. While there are many off-the-shelf solutions available, building your own custom trade copier with the MetaTrader API gives you full control, lower latency, and the ability to tailor it to your specific needs.
In this guide, we’ll walk through how to build a basic trade copier using MetaTrader (MT4/MT5), MQL, and external APIs. Whether you’re a developer, prop firm operator, or algo trader, this will serve as a practical starting point.
Table of Contents
What Is a Trade Copier?
A trade copier replicates trades from one account (the master) to one or more other accounts (the slaves). It’s used to:
Mirror trades across brokers or platforms
Manage multiple trading accounts from one central EA
Offer trade signals or manage investor accounts
Split execution across regulated vs. offshore brokers
By building your own trade copier, you avoid third-party fees, gain full transparency, and can optimize for speed and customization.
How a Custom Trade Copier Works
A typical MetaTrader-based copier includes:
Master EA (MetaTrader)
Detects trade actions (open, close, modify) and sends data via WebHook, file, or socket.Middleware (Bridge)
Receives trade signals and relays them to the target account/platform.Slave EA or API Target
Executes trades in the receiver account based on the received signal.
Tools and Technologies You’ll Need
MetaTrader 4 or MetaTrader 5 (preferably MT5 for better API support)
MQL5 or MQL4 for writing the EA
A VPS to host the master and slave terminals
Web server or middleware (Python, Node.js, or n8n for routing)
Optional: Database for logging signals and errors
Broker API credentials if targeting non-MetaTrader platforms
Step-by-Step: Build Your Own MetaTrader Trade Copier
Step 1: Create the Master EA
Your EA will monitor orders on the master account and send trade data when a new position is opened, modified, or closed.
Basic Logic in MQL5:
void OnTradeTransaction(const MqlTradeTransaction &trans, const MqlTradeRequest &request, const MqlTradeResult &result)
{
if (trans.type == TRADE_TRANSACTION_DEAL_ADD)
{
string json = "{\"symbol\":\"" + trans.symbol + "\",\"type\":\"" + IntegerToString(trans.deal_type) + "\",\"volume\":\"" + DoubleToString(trans.volume, 2) + "\"}";
SendWebRequest("https://yourserver.com/copier", json);
}
}
Step 2: Build the Middleware (Server or Script)
Your bridge or server receives trade data and relays it to the slave account.
Common tech stack:
Python Flask app to receive JSON
Node.js + Express for faster async handling
n8n for no-code/low-code workflows
Example pseudo-code in Python:
@app.route('/copier', methods=['POST'])
def copier():
trade = request.json
# parse trade data
# send to slave terminal via file or API
Step 3: Implement Slave Execution
You can write a Slave EA that reads trade instructions from:
A local file
Socket or TCP listener
HTTP request
Shared memory (advanced)
Sample logic (MQL5 pseudocode):
void OnTick()
{
string tradeData = ReadFile("trade.txt");
// parse JSON and place order using OrderSend()
}
Optional: Cross-Platform Copying
If you want to copy trades from MetaTrader to cTrader, IBKR, or another platform, your middleware needs to:
Parse the MetaTrader trade
Format the order for the target platform’s API
Handle authentication and response validation
For example, you could:
Receive the MT5 trade via WebHook
Convert to cTrader Open API format
Place a REST API call from your VPS to the cTrader account
Tips for Building a Fast and Reliable Trade Copier
Use a VPS with low latency to both master and slave brokers
Minimize polling intervals (use event-based triggers where possible)
Use structured JSON for all trade data
Log all events for auditing and debugging
Match trading conditions (e.g., leverage, symbols, lot sizing)
Pros and Cons of Building Your Own Trade Copier
Pros | Cons |
---|---|
Full customization | Requires programming knowledge |
No monthly subscription fees | Maintenance and testing required |
Low latency and private infrastructure | No support unless you build it |
Cross-broker and cross-platform support | Complexity increases with scale |
Who Should Build Their Own Copier?
This solution is ideal for:
Prop firms managing trader accounts
Algo traders executing across multiple brokers
Signal providers distributing trades to clients
Traders needing custom risk filters or logic
Hosting Your Trade Copier on a VPS
You’ll need a fast and reliable VPS to:
Run your master and slave MetaTrader terminals
Host your WebHook or bridge server
Maintain 24/7 uptime with low-latency execution
Explore NYCServers VPS Plans →
We offer optimized locations (LD4, NY4, TY3) for cross-broker low-latency hosting — ideal for copier setups.
Final Thoughts
Building your own MetaTrader trade copier gives you unmatched control, speed, and flexibility. With the right VPS and codebase, you can create a system tailored to your exact trading needs — and scale it across accounts, brokers, or even platforms.
If you’re ready to go beyond one-size-fits-all solutions, this is the way to do it.
Need Help Setting It Up?
Our team can help you build and deploy a MetaTrader trade copier on your VPS — custom-configured, secure, and optimized.