Telegram to MT5 Trade Copier
Reads gold trading signals from a Telegram channel and executes them on MetaTrader 5 with partial take-profits and breakeven.
Overview
A trader wanted signals from a Telegram channel executed automatically on his MetaTrader 5 account. We built a bot that listens to the channel, parses XAUUSD signals, checks price against the stop loss, places the trade through MetaAPI and manages it with staged take-profits and breakeven moves.
The Challenge
Signals arrive at all hours and are often edited after posting. Copying them by hand was slow and missed entries.
The Solution
Signal listener
Handles both new messages and later edits, since the provider builds each signal over 40 to 90 seconds.
Safe entry
Real-time price check with a stop-loss buffer before any order is placed.
Partial take-profits
Position closed in 20% steps across up to five TP levels, with stop moved to breakeven.
Management commands
Parsed from the channel: set breakeven, take partials, move SL.
How It Works
Telegram channel
Telethon listener (new + edit)
Signal parser
Price + SL buffer check
MetaAPI order on MT5
Monitor TPs → breakeven
Architecture
Listener
Telethon client on NewMessage and MessageEdited events.
Parser
Extracts side, entry, SL and TP levels for XAUUSD.
Execution
MetaAPI cloud SDK placing orders on MT5.
Monitor
Background task polling price every 3 seconds.
State
Processed signal IDs persisted so restarts never duplicate trades.
Hosting
Runs as a service on a Linux VPS with logs.
Engineering Highlights
- Live monitors update their TP list when a signal is edited after the trade opens.
- Duplicate-trade protection survives bot restarts.
- Every fix verified against raw logs and live tests before shipping.
Outcome
- Running on a demo MT5 account for live validation.
- Ready to switch to a live broker account.