Introduction
An overview of the Copy Trade plugin for real-time trade replication between master and follower accounts.
What is Copy Trade?
Brokeret Copy Trade is a native C++ MT5 Server Plugin that automatically replicates trades from master accounts to follower (copier) accounts in real-time. It runs inside the MT5 Trade Server process and monitors deals via the Server API — no external dependencies or services required.
How It Works
Trade Open Flow
- Master account opens a position (e.g. BUY 1.0 EURUSD)
- MT5 server fires a deal event
- Plugin checks if the account matches any configured master
- For each follower rule, the plugin:
- Calculates volume (multiplier or fixed)
- Determines direction (same or reverse)
- Sets comment to
cp:<master_position_id>for tracking - Executes the trade on the follower account
Trade Close Flow
- Master closes a position
- Plugin queries the follower's open positions
- Finds the matching position by its
cp:comment - Closes it with the correct direction and volume
Close By Support
MT5's Close By operation (closing a BUY against a SELL) uses a separate callback. The plugin handles both normal close and Close By to ensure all follower positions are closed correctly.
Lot Sizing Modes
| Mode | Example | Description |
|---|---|---|
| Multiplier | mult, 1.0 | Follower lot = master lot × multiplier |
| Multiplier | mult, 0.5 | Follower lot = half of master lot |
| Fixed | fixed, 0.01 | Follower always trades 0.01 lot regardless of master |
Trade Direction
| Direction | Description |
|---|---|
same | Follower copies the same direction (BUY→BUY, SELL→SELL) |
reverse | Follower trades opposite direction (BUY→SELL, SELL→BUY) |
Position Tracking
The plugin uses comment-based tracking to maintain master-follower position relationships:
- On open: follower position comment is set to
cp:<master_position_id> - On close: plugin finds the matching follower position by comment and closes it
- Survives server restarts — no in-memory state required for position matching
A built-in recursion guard ignores deals with cp: comments to prevent infinite loops.
Multi-Follower Support
One master can copy to multiple followers simultaneously. Each follower can have independent lot sizing and direction settings.
Master 1001
├── Follower 2001: multiplier 1.0, same direction
├── Follower 2002: multiplier 0.5, same direction
└── Follower 2003: fixed 0.01, reverse direction
Key Features
- Real-time trade replication — Copies trades as they happen via deal events
- Multi-follower rules — One master can copy to many followers
- Flexible lot sizing — Multiplier or fixed lot modes
- Reverse copy — Option to trade opposite direction
- Comment-based tracking — Survives server restarts
- Close By support — Handles MT5 hedge close operations
- REST API — Manage rules remotely without MT5 Admin access
- Rule persistence — API rules saved to file and survive restarts
- Live config reload — Rules update without server restart
Supported Entry Types
| Entry Type | Handled | Description |
|---|---|---|
ENTRY_IN | Yes | New position opened |
ENTRY_OUT | Yes | Position fully closed |
ENTRY_INOUT | Yes | Position reversed |
ENTRY_OUT_BY | Yes | Closed by hedge position |
Next Steps
- Installation — Get the plugin running on your MT5 server
- Parameters — Configure copy rules and plugin settings
- API Reference — Manage rules remotely via REST