CopyTraderAgent: A Desktop Copy Trade Manager for MetaTrader 5

CopyTraderAgent: A Desktop Copy Trade Manager for MetaTrader 5

Recently I organized and open-sourced a new project:CopyTraderAgent.

Project address:
https://github.com/long-dotcom/CopyTraderAgent

CopyTraderAgent is a Windows desktop copy trading manager for MetaTrader 5 , mainly used for multi-account trade execution, automated research, and trading system operation and maintenance verification.

It is not a trading strategy, nor does it judge market direction. It is more like an execution layer tool: when the master account performs operations such as opening, closing, reducing positions, modifying stop loss/take profit, or changing pending orders, the system is responsible for copying these changes to one or more sub-accounts.

Why build this project

Multi-account copy trading seems simple: the master account places an order, and the sub-accounts follow.

But in practice, many issues arise.

The symbol names on different MT5 servers may differ. For example, one platform might call it EURUSD, while another might call it EURUSDm; gold could be XAUUSD, or XAUUSDm.

Different sub-accounts may have different capital sizes, lot multipliers, Magic numbers, slippage, and order comment rules. The master account opens 0.10 lots, but that does not mean all sub-accounts should open 0.10 lots.

More critically, the system must know: which order of the master account corresponds to which order of the sub-account.

If there is only one order, the issue is not obvious. But once there are multiple positions in the same symbol and direction, combined with partial closing, SL/TP modifications, pending order execution, etc., order binding becomes important.

CopyTraderAgent mainly solves these execution-level problems.

Project Positioning

The positioning of CopyTraderAgent is clear:

It is not responsible for generating trading signals, only for copying execution.

Strategies can come from manual trading, EAs, scripts, or other systems. CopyTraderAgent only focuses on what trading changes have occurred in the master account and how these changes should be synchronized to the sub-account.

In simple terms:

交易策略 / 人工交易
        |
        v
主账户 MT5
        |
        v
CopyTraderAgent
        |
        v
多个子账户 MT5

Supports Local and Distributed Modes

The project currently supports three operating modes:

local             主账户 MT5 -> 本地子账户 MT5
master_publisher  主账户 MT5 -> Redis 事件流
child_executor    Redis 事件流 -> 本地子账户 MT5

If the master account and sub-account are on the same computer, you can use the local mode.

If the master account and sub-account are distributed on different machines, you can use Redis mode. The master side only publishes trading changes to Redis Stream, and the sub-side executor independently consumes events and completes execution.

This design separates the responsibilities of the master and sub sides: the master side only cares about trading events, while the sub side decides how to execute based on its own configuration, such as lot multiplier, symbol mapping, Magic, slippage, and Comment template.

Key Design Aspects

Strict Symbol Mapping

CopyTraderAgent uses strict symbol mapping.

For example:

XAUUSD=XAUUSD
EURUSD=EURUSDm

Only symbols with configured mapping will be copied. Unconfigured symbols will be skipped.

This design is conservative, but I believe it is necessary for trading execution tools. What automated systems fear most is not under-execution, but wrong execution. It is better to skip an unconfigured symbol than to place an order on the wrong symbol.

Comment binds master and sub orders

Enabled sub-accounts must configure a Comment template, which must include:

{master_ticket}

Recommended format:

COPY:{master_ticket}

This way, the master account's ticket can be written into the sub-account order comment, making it more stable for the system to identify the master-sub order relationship during position reduction, closing, or SL/TP modification.

If relying solely on "symbol + direction + Magic" matching, ambiguity easily arises in scenarios with multiple orders in the same direction.

Sub-account differentiated configuration

CopyTraderAgent does not simply replicate master account orders one-to-one to all sub-accounts.

Each sub-account can independently configure lot multiplier, symbol mapping, Magic, slippage, Comment template, and MT5 terminal path.

This makes it more of a multi-account execution manager than a simple copy script.

Operational stability

In addition to basic copy trading functionality, the project also implements some operational stability measures:

  • Retry if a sub-account execution fails.
  • Failure of one sub-account does not block others.
  • GUI log limits the maximum number of retained lines.
  • Redis Stream limits the maximum length to prevent infinite growth of event streams.
  • Sub-account error records limit the number retained.
  • Avoid duplicate market order copying after pending orders are filled.

These designs may not sound as appealing as "strategy returns," but they are crucial for execution-layer tools.

When a trading system runs long-term, the real headaches are often anomaly accumulation, duplicate execution, mismatches, log bloat, and untraceable states.

Suitable scenarios

CopyTraderAgent is suitable for:

  • MT5 multi-account copy trading research.
  • Local multi-MT5 terminal execution synchronization.
  • Master and sub-accounts distributed on different machines.
  • Different sub-accounts requiring different lot multipliers.
  • Different symbol names across brokers.
  • Separating the strategy layer from the execution layer.
  • Validating Redis event-stream-driven trade execution mode.

It is not suitable as a "download and profit" trading software. If the master account incurs losses, sub-accounts may also incur losses. It solves the execution replication problem, not the win rate of the strategy itself.

Future Directions

I will continue to improve in these directions:

  • More complete state persistence.
  • Clearer display of master-sub order binding relationships.
  • Stronger execution observability.
  • Disconnection recovery in Redis distributed mode.
  • Tracking and alerting for sub-account execution failures.
  • More edge case testing.

Summary

The core goal of CopyTraderAgent is simple:

Stably and controllably replicate trading changes from the master account to multiple MT5 sub-accounts.

It is not a strategy, does not predict market trends, and does not promise returns.

It focuses on more fundamental and engineering-oriented issues in trading automation: multi-account configuration, symbol mapping, order binding, event distribution, failure retry, log observation, and execution stability.

Project address:
https://github.com/long-dotcom/CopyTraderAgent