Telegram Alert With Emoji
- Utilità
- Thannawut Khankhat
- Versione: 1.0
Purpose:The Telegram Alert With Emoji sends real-time trading notifications to a Telegram chat or group for all trading activities in MT5, including new Positions (BUY/SELL), Pending Orders (BUY LIMIT, SELL LIMIT, BUY STOP, SELL STOP), Stop Loss/Take Profit (SL/TP) triggers, and closed Positions with profit/loss details. It includes a Rainbow Display on the chart and uses Global Variables to prevent duplicate notifications.
[MT4 Version ---> click.]
Key Features
-
Telegram Notifications:
-
Sends messages for:
-
New Positions (BUY/SELL)
-
Benefits
-
Real-time trade monitoring via Telegram
-
Prevents duplicate notifications
-
Visually appealing Rainbow Display
-
Compatible with all symbols and MT5 brokers
Limitations
-
Requires correct BotToken and ChatID
-
Needs https://api.telegram.org in MT5's Allowed URLs
-
MT5-specific (needs conversion for MT5)
User Manual
Requirements
-
Platform: MetaTrader 5 (MT5), latest version
-
Telegram Account:
-
Telegram Bot and chat/group for notifications
-
BotToken (e.g., 7717084123:YOUR_ACTUAL_TOKEN)
-
ChatID (e.g., -1002450008123 for "Auto Trade EA Community")
-
-
Internet Connection: For WebRequests to Telegram API
-
MT5 Settings: Enable WebRequest and AutoTrading
New Pending Orders (BUY LIMIT, SELL LIMIT, BUY STOP, SELL STOP)
-
-
SL/TP triggers
-
Closed Positions (TP, SL, or manual)
-
-
Supports emojis: 🟢 (BUY), 🔴 (SELL), 💰 (Take Profit), 💥 (Stop Loss), 🛑 (Manual Close), ⚡ (New Position), 📋 (New Order), 📊 (Closed Position)
-
Includes details: Ticket, trade type, lot size, open price, SL, TP, symbol, close reason, profit/loss, timestamp
-
-
Duplicate Notification Prevention:
-
Uses Global Variables and array tracking to send notifications only once per ticket
-
Cleans up Global Variables older than 1 hour
-
-
Rainbow Display:
-
Displays "Telegram Alert for all orders ...." at the top-left corner of the chart
-
Changes text color every second (red, orange, yellow, green, aqua, blue, magenta)
-
Black chart background for clarity
-
-
UTF-8 Support:
-
Supports UTF-8 encoding for correct emoji display
-
Uses parse_mode: HTML for formatted messages
-
-
Debugging:
-
Logs information in MT5's Experts/Journal tab (e.g., order counts, tickets, WebRequest results)
-
Helps diagnose issues like incorrect BotToken/ChatID or WebRequest failures
-
Benefits
-
Real-time trade monitoring via Telegram
-
Prevents duplicate notifications
-
Visually appealing Rainbow Display
-
Compatible with all symbols and MT5 brokers
Limitations
-
Requires correct BotToken and ChatID
-
Needs https://api.telegram.org in MT5's Allowed URLs
User Manual
Requirements
-
Platform: MetaTrader 5 (MT5), latest version
-
Telegram Account:
-
Telegram Bot and chat/group for notifications
-
BotToken (e.g., 7717084123:YOUR_ACTUAL_TOKEN)
-
ChatID (e.g., -1002450008123 for "Auto Trade EA Community")
-
-
Internet Connection: For WebRequests to Telegram API
-
MT5 Settings: Enable WebRequest and AutoTrading
Installation Steps
-
Obtain EA File:
-
Download TelegramAlert.mq5 or TelegramAlert.ex5
-
Copy to MQL5/Experts folder (e.g., C:\Program Files\MetaTrader 5\MQL5\Experts)
-
-
Set Up Telegram Bot:
-
Create a Bot via @BotFather:
-
Send /start and /newbot
-
Set name and get BotToken (e.g., 7717084534:YOUR_ACTUAL_TOKEN)
-
-
Add Bot to a Telegram group
-
Get ChatID using @GetIDsBot or https://api.telegram.org/bot<BotToken>/getUpdates
-
-
Update input:
-
Open TelegramAlert.mq5 in MetaTrader 5
-
Update:
input string BotToken = "YOUR_BOT_TOKEN_HERE"; input string ChatID = "YOUR_CHAT_ID_HERE";
Example:
input string BotToken = "7717084534:YOUR_ACTUAL_TOKEN"; input string ChatID = "-1002450008211";
-
-
Configure MT5:
-
Go to Tools > Options > Expert Advisors
-
Check:
-
Allow automated trading
-
Allow DLL imports (if needed)
-
Allow WebRequest for listed URL
-
-
Click OK
-
-
Attach EA to Chart:
-
Open a chart (e.g., GOLD, M5)
-
Drag TelegramAlert.ex5 to the chart or right-click > Attach to Chart
-
Verify BotToken/ChatID, check Allow live trading, and click OK
-
Confirm smiley face icon at top-right corner
-
Usage
-
Starting the EA:
-
Sends four test messages to Telegram:
Test Simple: Hello Telegram
Test Emoji (HTML): 🟢 💰 📊
Test Emoji (MarkdownV2): 😊 ✅ 🚀
Test Emoji (Plain): 🟢 💰 📊
-
Verify receipt and emoji display
-
-
Notifications:
-
New Position:
⚡ New Position Alert!
-------------------------
Ticket: 123456
Type: 🟢 BUY
Lot: 0.10
Price: 1800.12345
SL: 1795.00000
TP: 1805.00000
Symbol: GOLD
Time: 2025.09.21 02:30:00
-------------------------
-
New Pending Order:
📋 New Order Alert!
-------------------------
Ticket: 123457
Type: 🟢 BUY LIMIT
Lot: 0.10
Price: 1795.00000
SL: 1790.00000
TP: 1800.00000
Symbol: GOLD
Time: 2025.09.21 02:30:00
-------------------------
-
SL/TP Trigger:
💰 TAKE PROFIT Alert!
-------------------------
Ticket: 123456
Type: BUY
Symbol: GOLD
TAKE PROFIT Price: 1805.00000
Close Price: 1805.00010
Time: 2025.09.21 02:35:00
-------------------------
-
Closed Position:
📊 Position Closed Alert!
-------------------------
Ticket: 123456
Type: BUY
Lot: 0.10
Symbol: GOLD
Price: 1805.00010
SL: 1795.00000
TP: 1805.00000
Reason: 💰 TAKE PROFIT
Profit: 50.00 USD
Time: 2025.09.21 02:35:00
-------------------------
-
-
Rainbow Display:
-
Displays "Telegram Alert for all orders ...." at top-left
-
Color changes every second (red, orange, yellow, green, aqua, blue, magenta)
-
Black chart background
-
-
Debugging:
-
Check Experts/Journal tab for logs, e.g.:
-
EA Initialized, OrdersTotal: X, OrdersHistoryTotal: Y
-
New Position Alert Sent, Ticket: 123456, Message: [full message]
-
Telegram response: {"ok":true,...}, Sent message: [message]
-
-
Troubleshooting
-
No Notifications:
-
Verify BotToken/ChatID
-
Test via https://api.telegram.org/bot<BotToken>/sendMessage?chat_id=<ChatID>&text=Test
-
Ensure https://api.telegram.org is in Allowed URLs
-
Check logs for WebRequest error: [code]
-
-
Incorrect Emoji Display:
-
Confirm parse_mode: HTML or MarkdownV2
-
Test with initial messages
-
Try parse_mode: "" (Plain)
-
-
EA Not Working:
-
Check smiley face icon
-
Ensure Allow automated trading is enabled
-
Test with new Position/Order
-
-
MetaEditor Warnings:
-
For warnings like possible loss of data due to type conversion:
-
Use string ticketStr = IntegerToString(ticket)
-
Warnings do not affect functionality
-
-
