Professional library of Telegram Bot integration for MetaTrader 5. A complete solution for sending trading signals, screenshots, reports and real-time notifications to Telegram channels and groups.
#include <TelegramBot.mqh> CTelegramBot bot; int OnInit() { // Initialising the bot if(!bot.Initialize("YOUR_TOKEN"., "YOUR_CHAT_ID")) { Print("Failed to initialise bot"); return INIT_FAILED; } // Sending a test message bot.SendMessage("Bot successfully connected!"); // Send a screenshot of the graph bot.SendChartScreenshot("Current market situation."); return INIT_SUCCEEDED; }
bool SendMessage(string text); bool SendHTMLMessage(string text); bool SendMarkdownMessage(string text); bool SendMessageToAll(string text);
bool SendTradeSignal(ENUM_SIGNAL_TYPE type, string symbol, double price); bool SendPositionOpened(ulong ticket, string symbol, ENUM_POSITION_TYPE type, double volume, double price); bool SendPositionClosed(ulong ticket, string symbol, double profit, double commission, double swap);
bool SendPhoto(string file_path, string caption); bool SendDocument(string file_path, string caption); bool SendChartScreenshot(); bool SendChartScreenshot(string caption);
bool SendAccountStatus(); bool SendDailyReport(); bool SendWeeklyReport(); bool SendMonthlyReport();
bool SendRiskAlert(double drawdown_percent); bool SendMarginWarning(double margin_level); bool SendStopOutWarning();
The package includes a fully functional example of the Expert Advisor, demonstrating:
string message = "<b> Жирный текст</b>\n"; message += "<i> Курсив</i>\n"; message += "<code> Моноширинный код</code>\n"; message += "<a href='http://example.com'> Ссылка</a>"; bot.SendHTMLMessage(message);
string message = "Bold text{\n}"; message += "Italics."; message += "Monospaced code."; message += "[Link](http://example.com)"; bot.SendMarkdownMessage(message);
The library includes complex error handling:
This library is provided "as is" for use in MetaTrader 5. It is free for personal and commercial use.
Forex Trading Blueprint
(Stepan Sinic)
This software is provided "as is" without warranty of any kind. Trading involves a substantial risk of loss and is not suitable for all investors. Past performance is not an indicator of future results.
If you find this library useful, please rate it on MQL5 CodeBase!
Find BotFather
Create a new bot
Configure the bot
Solution: 1. Tools → Settings → Advisors 2. ✓ Allow WebRequest for the following URLs 3. Add: https://api.telegram.org 4. Restart MT5
Check: 1. Correct token 2. Chat ID is correct 3. Internet connection 4. WebRequest settings
Possible causes: 1. API limit exceeded (30 messages/minute) 2. Incorrect HTML format in the message 3. Message is too long (>4096 characters)
bot.SendTradeSignal(SIGNAL_BUY, "EURUSD", 1.1850, 1.1800, 1.1900);
string caption = "<b> Точка входа</b>\n"; caption += "Пара: EURUSD\n"; caption += "Тип: BUY\n"; caption += "Цена: 1.1850"; bot.SendChartScreenshot(caption);
bot.SendAccountStatus();
// Automatically send balance, equity, margin, etc. // In OnTimer() advisor if(TimeHour(TimeCurrent()) == 23 && TimeMinute(TimeCurrent()) == 0) { bot.SendDailyReport(); }
double drawdown = CalculateDrawdown(); // Your calculation function if(drawdown > 20.0) // The drawdown is more than 20% { bot.SendRiskAlert(drawdown); }
[POSITION OPENED] ↑ ================ Ticket: #12345678 Symbol: EURUSD Type: BUY Volume: 0.10 Price: 1.18500 Time: 2024.01.15 10:30 ================
[POSITION CLOSED] ================ Ticket: #12345678 Symbol: EURUSD Profit: +125.50 USD Commission: -2.00 Swap: -0.50 Total: +123.00 USD Time: 2024.01.15 14:45 ================
[DAILY REPORT] ================ Date: 2024.01.15 ACCOUNT SUMMARY ---------------- Balance: 10,125.50 USD Equity: 10,250.00 USD Floating P/L: +124.50 USD TRADING ACTIVITY ---------------- Trades Today: 5 Today's Result: +250.00 USD Open Positions: 2 BOT STATISTICS ---------------- Messages Sent: 45 Signals Sent: 8 Success Rate: 98.5% ================
Translated from Russian by MetaQuotes Ltd.
Original code: /ru/code/63585
OHLC Candles with Ask and Bid
A candlestick chart which connects the ask price and bid price to the high and low of the candles
Assisted position closing tool
This is an auxiliary take profit and stop loss tool, which can help you to tight stop loss and dynamic take profit. Updated
OHLC Candles with extreme tick price tracking
This is an OHLC candlestick chart which records the highest ask and lowest bid on each new bar
TimeBar
A simple information indicator that shows the remaining time until the bar closes, as well as the time elapsed since the bar opened and the current time.