If you've ever tried to build a Telegram-to-MT5 signal copier, you've probably run into the same headaches I did. One of the trickiest issues? Time handling. Let me walk you through a common bug I fixed recently—and how it turned into something much bigger.
The Problem: A Time Bomb in Your Code
I was working on a signal copier that reads trading signals from a JSON API and executes them in MT5. The logic seemed straightforward:
double timestamp = js["timestamp"].ToDbl(); datetime now = TimeCurrent(); // Check if signal is too old (20 seconds max) if((double)now - timestamp > 20.0) { Print("More than 20 seconds have passed, can't open trade!"); return; }
Looks fine, right? Wrong.
What Was Actually Broken:
- Casting datetime to double : datetime in MQL5 is an integer (seconds since 1970). Casting it to double introduces floating-point precision issues that can cause comparisons to fail unpredictably.
- Timezone Mismatch: TimeCurrent() returns the broker's server time (which could be UTC+2, UTC+3, or any other offset). But the JSON timestamp from a web API is almost always UTC. If your broker runs on UTC+3, you're off by 10,800 seconds—your 20-second freshness check becomes useless.
- No UTC Comparison: The code compares apples to oranges—broker server time against UTC without any conversion.
The Fix: Proper Time Handling in MQL5
Here's the corrected version that handles both the type issue and the timezone problem:
// Parse timestamp from JSON (UTC, in seconds) double timestamp_double = js["timestamp"].ToDbl(); datetime timestamp = (datetime)timestamp_double; // Clean cast // Get current UTC time from MetaTrader datetime now_utc = TimeGMT(); // Always returns UTC // Check if signal is too old (20 seconds max) if(now_utc - timestamp > 20) { Print("Current UTC time: ", now_utc); Print("Signal time (UTC): ", timestamp); Print("Difference: ", now_utc - timestamp, " seconds"); Print("Signal is too old—can't open trade!"); return; }
Key Changes:
- No more double casting: use datetime directly for integer arithmetic
- Use TimeGMT() instead of TimeCurrent() for UTC comparison
- Convert JSON timestamp explicitly to datetime without floating-point operations
Pro tip: If your JSON timestamp uses milliseconds (13 digits), divide by 1000 first:
datetime timestamp = (datetime)(js["timestamp"].ToDbl() / 1000.0);
From Fix to Full Product: The Telegram to MT5 Signal Copier
While solving this time bug, I realized there was a bigger opportunity: automating the entire signal-copying workflow from Telegram to MT5.
That's how the Telegram to MT5 Signal Copier (also known as SpackCopier Bot) was born.
What It Does
The copier listens to your Telegram channels, extracts trading signals automatically—including symbol, direction, entry price, stop loss, and take profit—and executes them instantly in MT5.
Key Features:
- Direct Telegram Integration: Connects to public or private Telegram channels you're a member of
- Automatic Signal Parsing: Extracts trade instructions from messages using pattern recognition
- Instant Trade Execution: Opens, modifies, or closes positions automatically
- Broad Symbol Support: Works with Forex, metals, and even synthetic indices like Boom/Crash and Volatility indexes
- No Admin Rights Needed: Runs without requiring administrator privileges on your PC
- Pre-built Application: No coding required—just configure and run
What's Included:
- A ready-to-run .exe application(Signal Listener)
- Example MT5 Expert Advisor demonstrating signal reading and execution
- Step-by-step setup guide
- Integration and customization support
Who It's For:
- Traders receiving signals via Telegram
- Developers building automated trading systems
- Signal providers distributing alerts through Telegram
- Anyone wanting to eliminate manual trade copying
Setup Overview
- Install the copier application on your Windows PC or VPS
- Configure your Telegram credentials and target channel
- Attach the MT5 EA to any chart with Algo Trading enabled
- Start copying signals automatically
Requirements:
- Telegram account (with access to the target channel)
- Windows PC or VPS
- MetaTrader 5 terminal
- Internet connection
The Bottom Line
That simple timezone bug turned into a valuable lesson and a powerful tool. Whether you're building your own copier from scratch or using a ready-made solution, proper time handling is critical for reliable automated trading.
Ready to automate your Telegram signals? Check out the Telegram to MT5 Signal Copier on the MQL5 Market.
Trading carries risk. Always test on a demo account first and trade responsibly.


