GMRFX CopyTrade Local and Lan
- Yardımcı programlar
- Sürüm: 1.0
- Etkinleştirmeler: 5
# GMRFX Copytrade Local & Lan
> **Copy-Trade Master/Slave — One EA, File-Based Sync, Zero Network Config.**
> Copy trades between MT5 terminals on the same PC, across your local network, or over the internet — using nothing but a shared folder.
---
**Version:** 1.00
**Category:** Trade Copiers / Utilities
---
## What Is This?
**GMRFX Copytrade Local & Lan** is a single Expert Advisor that handles both **Master** (sender) and **Slave** (receiver) roles for copy trading. Pick your mode from a dropdown — done.
Unlike socket-based copiers that require IP addresses, port forwarding, and firewall rules, this EA uses a simple `.csv` file as its communication bridge. Your operating system handles the networking. You just point both EAs to the same folder.
### Where It Works
| Setup | Sync Method | Delay |
|---|---|---|
| **Same PC, multiple MT5 terminals** | Built-in (Common\Files\) | Instant |
| **2 PCs, same LAN** | Syncthing (free, P2P) or Windows SMB share | 0.5–2 sec |
| **2 PCs, different locations (internet)** | Syncthing, Dropbox, Google Drive, OneDrive | 2–5 sec |
| **PC to VPS** | Any cloud sync tool | 2–5 sec |
---
## Key Features
### One EA, Two Modes
No more juggling `Master_EA.ex5` and `Slave_EA.ex5`. A single file, a single parameter, instant mode switch. Version updates: one file.
### File-Based Communication
The Master writes position snapshots to `state.csv`. The Slave reads and reconciles. No sockets. No DLLs. No IP configuration. No port forwarding.
### Atomic Writes
Master writes to `.tmp` first, then renames to `.csv`. The Slave always reads a complete, uncorrupted file — even during concurrent access.
### Cross-PC Ready
`InpSyncFolder` can point to any folder — local, network share, or a cloud-synced directory. Use Syncthing (free, open-source, P2P), Dropbox, Google Drive, or OneDrive to bridge computers anywhere in the world.
### Smart Slave Logic
- **Anti-Reopen** — remembers positions you closed manually. Won't reopen them.
- **Age Gate** — only copies positions opened within N seconds. Filters stale signals.
- **Reverse Copy** — invert direction (Buy ↔ Sell). SL and TP swapped too.
- **Volume Control** — ratio mode (0.5x, 2x Master lot) or fixed lot.
- **Symbol Filter** — comma-separated list. Empty = all symbols.
- **Suffix Support** — handles broker symbol differences (EURUSD → EURUSD.r).
- **SL/TP Copy** — optionally copy Stop Loss and Take Profit from Master.
- **Spread Limit** — skip trades when spread exceeds your threshold.
- **Offline Detection** — detects Master shutdown. Optionally auto-close all Slave positions.
- **Bilingual Logs** — English or Bahasa Indonesia, selectable in parameters.
### Lightweight & Pure MQL5
No external DLLs. No custom indicators. No web requests. Runs entirely in `OnTimer()`. Minimal CPU and memory footprint.
---
## Why File-Based Sync?
| Approach | Problems |
|---|---|
| **Socket / TCP** | Complex IP config, port forwarding, firewall rules, often blocked by VPS providers |
| **DLL-based** | Security warnings on MT5, platform-dependent, fragile |
| **Web server / API** | Requires hosting, latency, subscription costs |
| **File-based (this EA)** | Zero network config. OS handles sync. Works on any setup. Free. |
**The folder is the protocol.** Your OS (or Syncthing/Dropbox) already knows how to move files between computers reliably. This EA just reads and writes CSV — and lets the OS do the heavy lifting.
---
## How It Works
```
PC MASTER PC SLAVE
┌──────────────────────┐ ┌──────────────────────┐
│ MT5 + Master EA │ │ MT5 + Slave EA │
│ │ write │ │
│ OnTimer() every N ms │──────────────│ OnTimer() every N ms │
│ -> write state.csv │ Syncthing │ -> read state.csv │
│ -> atomic .tmp │ /Cloud │ -> reconcile trades│
│ │──────────────│ │
└──────────────────────┘ └──────────────────────┘
│ │
└──────── SyncFolder ────────────────┘
(Common\Files\CopyTrade\)
```
1. **Master EA** writes current positions to `state.csv` (via `.tmp` atomic write) every `InpRefreshMs` milliseconds.
2. **Folder sync** (Syncthing, Dropbox, etc.) copies the file to the Slave PC.
3. **Slave EA** reads `state.csv`, matches positions by unique ID, opens/modifies/closes trades to mirror the Master.
---
## Parameters Overview
### Mode Selection
| Parameter | Options | Description |
|---|---|---|
| `InpMode` | Master / Slave | Select the EA role |
### Shared Settings
| Parameter | Default | Description |
|---|---|---|
| `InpSyncFolder` | `CopyTrade` | Folder path. Default = `Common\Files\CopyTrade\`. Point to Syncthing/Dropbox for cross-PC. |
| `InpChannel` | `default` | Channel name. Master and Slave must match. |
| `InpRefreshMs` | `100` | Refresh interval in milliseconds |
### Master Settings
| Parameter | Default | Description |
|---|---|---|
| `InpMaxCopyStaleSec` | `60` | Max snapshot age accepted by Slave. 0 = Slave uses own setting. |
| `InpMagicFilter` | `0` | Filter by magic number. 0 = copy all. |
| `InpIncludeManual` | `true` | Include manual trades (magic=0). |
| `InpMasterVerbose` | `false` | Extra logging for debugging. |
### Slave Settings
| Parameter | Default | Description |
|---|---|---|
| `InpUILanguage` | `English` | Log language: English or Bahasa Indonesia |
| `InpSlaveMagic` | `991001` | Magic number for Slave positions |
| `InpMaxStaleSec` | `60` | Fallback stale limit if Master doesn't send one |
| `InpVolumeMode` | `VOL_RATIO` | Volume mode: ratio or fixed lot |
| `InpRatio` | `1.0` | Volume multiplier (for ratio mode) |
| `InpFixedLot` | `0.01` | Fixed lot size (for fixed mode) |
| `InpReverse` | `false` | Reverse direction (Buy↔Sell) |
| `InpCopyClose` | `true` | Close Slave positions when Master closes |
| `InpCloseSlaveOnMasterShutdown` | `false` | Close all when Master goes offline |
| `InpCopySL` | `true` | Copy Stop Loss from Master |
| `InpCopyTP` | `true` | Copy Take Profit from Master |
| `InpUseSuffix` | `false` | Enable symbol suffix |
| `InpSuffix` | *(empty)* | Suffix string (e.g. `.r`, `m`) |
| `InpSlippagePts` | `20` | Maximum slippage in points |
| `InpMaxSpreadPts` | `0` | Max spread (0 = disabled) |
| `InpSymbolFilter` | *(empty)* | Filter symbols (comma-separated) |
| `InpNoReopenAfterManualClose` | `true` | Remember manually closed positions |
| `InpCopyOpenValidSec` | `20` | Max position age to copy (0 = off) |
| `InpSlaveVerbose` | `false` | Extra logging for debugging |
---
## Quick Start
### Same PC
1. Attach EA to Terminal A chart → Mode = **Master** → `InpChannel = "default"` → OK
2. Attach EA to Terminal B chart → Mode = **Slave** → `InpChannel = "default"` → OK
3. Done. Instant copy.
### Different PCs (via Syncthing)
2. Share `Common\Files\CopyTrade\` folder between them.
3. Both EAs: `InpSyncFolder = "CopyTrade"` (default).
4. Done. ~1-2 sec delay on LAN.
---
## Requirements
- MetaTrader 5 (any build supporting `#include <Trade\Trade.mqh>`)
- Both Master and Slave must have the same symbols available
- For cross-PC: any folder sync tool (Syncthing recommended — free, P2P, no account needed)
- Algo Trading must be enabled on all terminals
---
## What You Get
- `GMRFX_Copytrade_Local&Lan.ex5` — the EA
- Comprehensive user manual (PDF)
- 30 parameters with sensible defaults
- Works out of the box with zero configuration for same-PC setups
---
*Free product. No restrictions, no subscriptions, no hidden calls.*
