How kr0st/trade_replicator works
Project type and purpose
• This is an open-source Forex trade-replicator tool (not a full-stack web app).
• It consists of two MQL4 scripts (master and slave) for MetaTrader 4 and a Java-based master strategy for JForex.
• Purpose: copy trades from a “master” account to one or more “slave” accounts via a PostgreSQL database.
File structure
• Top-level files:
• trade_replicator_master.mq4 – MT4 master script
• trade_replicator_slave.mq4 – MT4 slave script
• TradeReplicatorMaster.java – JForex master strategy
• readme.txt / license.txt – documentation & BSD license
• No separate “src” or “lib” folders: all components live at root.
• The MQL4 scripts depend on the PostgreMQL4 DLL (external library) to connect to PostgreSQL.
• The Java strategy depends on a PostgreSQL JDBC driver.
Extract architecture insights from the README
• Masters generate and write trade events to two tables: master_trades and slave_trades.
• Slave scripts poll the DB (once per second) for new/closed trades and execute them in MT4.
• Java version runs inside JForex, writes to the same DB.
• Configuration is done by embedding parameters (DB credentials, master IDs) in script code or at runtime.
Detail to capture
• Master ID generation & uniqueness constraint
• Table creation step on first run
• Error handling path (slave writes error code back to DB)
• Multi-master subscription capability (slave side can list multiple master IDs)