Local Trade Copier via Named Pipes IPC
- Utilità
- Hayyu Imam Muhammad
- Versione: 2.15
- Attivazioni: 10
Local Trade Copier is a single-file MT5 Expert Advisor designed for fast local trade copying between two MetaTrader terminals running on the same PC. It can operate in either Sender (Host) mode, which captures and publishes trade activity from the source terminal, or Receiver (Client) mode, which reads that activity and reproduces it on the target terminal with flexible controls for symbol mapping, direction, lot sizing, SL/TP copying, and pending-order handling. Its main advantage is the use of Named Pipes IPC through a local helper server: compared with FILE_COMMON methods, it avoids repeated shared-file reading and writing on disk, reduces file-access overhead, and is generally better suited for low-latency, lightweight, same-machine communication when both terminals are running on the same Windows system.
In practice, this architecture provides a more responsive local trade-copying workflow than traditional file-based synchronization. While FILE_COMMON is simple and widely compatible, it still depends on repeated file polling and disk I/O. By contrast, the Named Pipes IPC approach is designed for faster local message delivery between processes, making it a more suitable transport layer for a trade copier that aims to be quick, efficient, and stable on a single computer.
Input parameters
01. General Settings
Role
Defines the EA role.
- ROLE_SENDER: the EA acts as the source terminal and sends trade events.
- ROLE_RECEIVER: the EA acts as the target terminal and copies received events.
ChannelName
The communication channel name.
Both terminals and the local helper server must use the same value to communicate with each other.
SharedBufferKB
The size of the internal event buffer in kilobytes.
A larger value allows more event text and event history to remain available before older data is trimmed.
EnableNamedPipeIPC
Enables or disables the Named Pipes IPC transport.
If disabled, the EA can still be attached without immediately trying to use the pipe communication layer.
02. Sender (Host) Settings
SenderTradeFilterMode
Specifies which sender trades are allowed to be transmitted.
- HOST_FILTER_ALL: send all eligible trades
- HOST_FILTER_MANUAL_ONLY: send only manual trades
- HOST_FILTER_MAGIC_ONLY: send only trades matching SenderMagicNumber
SenderMagicNumber
The magic number used when SenderTradeFilterMode is set to magic-only filtering.
Only trades with this magic number will be published.
SenderAllowedSymbols
A sender-side symbol filter.
Leave it empty to allow all symbols, or restrict transmission to selected symbols only.
SenderSendSnapshotOnInit
If enabled, the sender immediately publishes the current open-position snapshot when the EA starts.
This is useful when the receiver should synchronize with already-open trades after startup.
SenderSyncSLTPChanges
If enabled, stop-loss and take-profit modifications on the sender side are transmitted to the receiver.
SenderSyncPendingOrders
If enabled, pending-order creation, modification, and cancellation events are also transmitted.
SenderResetSharedBufferOnInit
If enabled, the sender clears or resets the shared communication buffer when it starts.
This helps prevent stale event data from a previous session from being reused.
SenderScanIntervalMilliseconds
The sender-side timer interval, in milliseconds.
It controls how frequently the sender checks for changes such as open/close events, SL/TP updates, and pending-order updates.
03. Receiver (Client) Settings
ReceiverHostEventFilterMode
Specifies which host events the receiver will accept.
- EVENT_FILTER_ALL: accept all host events
- EVENT_FILTER_MANUAL_ONLY: accept only host events coming from manual trades
- EVENT_FILTER_MAGIC_ONLY: accept only host events matching ReceiverAllowedHostMagic
ReceiverAllowedHostMagic
Used when receiver-side host-event filtering is set to magic-only mode.
Only host events with this magic number will be copied.
ReceiverAllowedHostSymbols
A receiver-side filter for incoming host symbols.
Leave it empty to accept all symbols, or use it to limit copying to selected source symbols only.
ReceiverSymbolMap
Maps host symbols to client symbols.
This is useful when the sender and receiver brokers use different symbol names, suffixes, or contract labels.
ReceiverMagic
The magic number assigned to positions or orders opened by the receiver EA.
It helps distinguish copied trades from manual trades or other EAs on the client terminal.
ReceiverDirectionMode
Defines how the copied trade direction is handled.
- COPY_REVERSE: reverse the host direction
- COPY_SAME_AS_HOST: keep the same direction as the host
In the current version, the default mode is COPY_SAME_AS_HOST.
ReceiverLotMode
Defines how the copied lot size is calculated.
- LOT_MULTIPLIER_FROM_HOST: use the host lot size multiplied by ReceiverHostLotMultiplier
- LOT_FIXED: always use ReceiverFixedLot
ReceiverHostLotMultiplier
The multiplier applied to the host lot size when ReceiverLotMode is set to multiplier mode.
ReceiverFixedLot
The fixed lot size used when ReceiverLotMode is set to fixed mode.
ReceiverMaxDeviationPoints
Maximum slippage or deviation allowed when the receiver sends market orders.
ReceiverCopySLTP
If enabled, the receiver also applies the sender’s stop-loss and take-profit values.
ReceiverCopyBrokerPendingOrders
If enabled, copied pending orders are placed as real broker-side pending orders on the receiver terminal.
ReceiverEnableVirtualPending
If enabled, pending orders can be handled virtually on the receiver side rather than always being placed immediately as broker-side pending orders.
ReceiverVirtualPendingBufferPoints
Additional point buffer used for virtual pending execution logic.
This can help control how closely the virtual trigger follows the original pending level.
ReceiverPollIntervalMilliseconds
Receiver-side polling interval, in milliseconds.
It controls how frequently the receiver checks the pipe/helper server for new trade events.
Summary of practical use
For normal use, the Sender should be attached to the source terminal and the Receiver to the destination terminal, while both sides use the same ChannelName . If you want the receiver to match currently open trades at startup, enable SenderSendSnapshotOnInit . If you want copied trades to behave exactly like the host side, keep ReceiverDirectionMode on COPY_SAME_AS_HOST. If brokers use different symbol names, configure ReceiverSymbolMap accordingly.
