Friday night dinner. Your phone buzzes. Telegram notification:
EURUSD BUY 0.5 Lot @ 1.0847 | SL: 1.0817 | TP: 1.0907 | 21:35:02
Your EA just opened a long position on the VPS. Entry, stop loss, take profit — all visible at a glance. You put the phone down and continue eating.
This takes a Telegram bot, a few dozen lines of MQL5, and about an hour to set up. Once running, you never have to wonder what your EA is doing while you're away from the screen. At FXTool, we added Telegram notifications to our own EAs early on — it changed how we monitor live accounts. Instead of logging into the VPS multiple times a day, we just glance at the phone. Some of our EAs now ship with Telegram support as a built-in parameter.
What the bot can do
Level 1 — trade notifications. Every time the EA opens, closes, or modifies a position, your phone gets a message with direction, lot size, price, stop loss, and take profit. When a trade closes, it includes the P&L.
Level 2 — scheduled account reports. A daily summary at a set time: balance, equity, margin level, open positions, daily P&L. You know your account's health without opening the VPS.
Level 3 — remote commands. Send /pause and the EA stops opening new positions. /resume restarts it. /closeall closes everything. /status returns current account info. You're on the train, NFP is about to drop, one message pauses the EA.
Level 4 — signal distribution. Forward trading signals automatically to a private Telegram channel. Subscribers pay monthly for access. This is a monetization channel for profitable EAs, similar to MQL5 signals but on a platform you control.
Step 1: create the bot (5 minutes)
Open Telegram, search for @BotFather — this is Telegram's official tool for creating and managing bots. Send /newbot. Choose a display name and a username ending in bot.
BotFather gives you an API token:
6123456789:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw
Save this token. It's the key to controlling your bot.
Get your Chat ID: send any message to your new bot, then open in a browser:
https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates
Find "chat":{"id": in the JSON response. That number is your Chat ID.
Step 2: configure MT5
In MT5: Tools → Options → Expert Advisors → add to the allowed URL list:
https://api.telegram.org
Without this, WebRequest() calls get blocked silently. This is the most common setup mistake — the code is correct but messages never send because the URL isn't whitelisted. If you're new to MT5, check our EA installation guide first — it covers the Options panel in detail.
Core code: sending trade notifications
string BotToken = "YOUR_TOKEN_HERE";
string ChatID = "YOUR_CHAT_ID";
bool SendTelegramMessage(string message)
{
string url = "https://api.telegram.org/bot" + BotToken + "/sendMessage";
string params = "chat_id=" + ChatID + "&text=" + message + "&parse_mode=HTML";
char post[], result[];
string headers = "Content-Type: application/x-www-form-urlencoded\r\n";
StringToCharArray(params, post, 0, WHOLE_ARRAY, CP_UTF8);
int res = WebRequest("POST", url, headers, 5000, post, result, headers);
if(res != 200)
{
Print("Telegram send failed, code: ", res);
return false;
}
return true;
}
Call this after successful OrderSend:
void NotifyTrade(string symbol, string dir, double lots,
double price, double sl, double tp)
{
string msg = symbol + " " + dir + " " + DoubleToString(lots, 2) + " Lot"
+ "\nEntry: " + DoubleToString(price, 5)
+ "\nSL: " + DoubleToString(sl, 5)
+ "\nTP: " + DoubleToString(tp, 5)
+ "\nTime: " + TimeToString(TimeCurrent(), TIME_SECONDS);
SendTelegramMessage(msg);
}
Daily account reports
Add a time check in OnTick() or OnTimer():
datetime lastReport = 0;
void CheckDailyReport()
{
MqlDateTime dt;
TimeCurrent(dt);
if(dt.hour == 8 && dt.min == 0 && TimeCurrent() - lastReport > 3600)
{
double bal = AccountInfoDouble(ACCOUNT_BALANCE);
double eq = AccountInfoDouble(ACCOUNT_EQUITY);
int pos = PositionsTotal();
string report = "=== Daily Report ==="
+ "\nBalance: $" + DoubleToString(bal, 2)
+ "\nEquity: $" + DoubleToString(eq, 2)
+ "\nPositions: " + IntegerToString(pos)
+ "\nTime: " + TimeToString(TimeCurrent());
SendTelegramMessage(report);
lastReport = TimeCurrent();
}
}
Remote commands
The EA periodically polls Telegram's getUpdates endpoint (every 3–5 seconds) and checks for command messages. When it finds /pause, it sets a global flag to stop opening positions. /resume resets it. /closeall iterates through all positions and closes them.
MQL5 doesn't have a native JSON parser, but for simple commands, StringFind(response, "/pause") is enough. Full JSON parsing is overkill for this use case. (If you want to generate the polling and command-handling boilerplate faster, AI-assisted coding tools can write a working first draft in minutes.)
Security: only respond to your authorized Chat ID. Add a check:
if(senderChatId != MyAuthorizedChatID)
{
SendTelegramMessage("Unauthorized access");
return;
}
Signal distribution for income
If your EA has been profitable for 3+ months with stable returns, you can sell signals via Telegram.
Create a private Channel (not a group). Add your bot as admin. In your EA code, send a copy of each trade signal to the channel's Chat ID (starts with -100...).
Charging model: monthly subscription ($20–50), paid via any method you choose. Send subscribers the channel invite link. Rotate the link monthly — non-renewers lose access naturally.
Signal format should be clean and professional:
EURUSD BUY Signal
Entry: 1.0847
SL: 1.0817 (30 pips)
TP: 1.0907 (60 pips)
R:R: 1:2
Time: 2025-03-14 21:35 UTC
Don't include your lot size or account balance. Subscribers decide their own position sizing based on their capital.
Security
Never include your account number in messages. Bot Token is a password — if leaked, go to BotFather and /revoke to regenerate immediately. Don't put tokens or passwords in EA input parameters (visible in clear text on the MT5 interface). Store them in the code or an encrypted config file.
Use private channels for signal distribution, never public ones. Public channel content is visible to everyone — you'd be giving away your signals for free.
Why Telegram over alternatives
MT5's built-in push notification sends to the MetaTrader mobile app. Simple format, no commands, no channels, no two-way interaction.
Email has delays (seconds to minutes) and no bidirectional communication. You can't send commands back to the EA by replying to an email.
Telegram: free API, excellent Bot API documentation, global availability, supports two-way messaging, supports channels for distribution. The only limitation is availability in certain regions, but since your EA runs on an overseas VPS, that's typically not an issue. If you're comfortable with Python, you could also build a more advanced monitoring dashboard using a Python–MT5 hybrid approach — but for most traders, pure MQL5 + Telegram is more than enough.
FAQ
WebRequest returns error -1. Why?
You didn't add https://api.telegram.org to MT5's allowed URL list. Tools → Options → Expert Advisors → URL list. Restart the EA after adding.
Messages work sometimes but not always?
Network instability between your VPS and Telegram's servers (in Europe). Increase the WebRequest timeout from 5000 to 10000 milliseconds. If your VPS is in Asia, occasional latency spikes are normal.
Can I send chart screenshots?
Yes, using ChartScreenShot() to save an image file and Telegram's sendPhoto API to upload it. Requires multipart form upload in MQL5, which is complex. Get text notifications working first, add images later.
Can one bot serve multiple EAs?
Yes. All EAs use the same Bot Token and Chat ID. Add the EA name at the start of each message to identify the source: [TrendEA] EURUSD BUY.... Every EA in the FXTool marketplace that supports Telegram integration uses this convention.
About the author: The FXTool team builds and tests MetaTrader trading tools daily. We run every EA we sell on live accounts and publish the results. This guide reflects what we've learned from building 50+ EAs and working with thousands of retail traders.
Forex trading involves significant risk and may result in total loss of capital. This article is for educational purposes only and is not investment advice. Understand the risks and consider your financial situation before trading.