Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

MT5 to Telegram Professional Library - Library for MetaTrader 5

author blogger | 970 reads | 0 comments |
#include

CTelegramBot robot; integer initialization ()
{
// Initialize the bot if (!bot.initialize( "your_token" , "your_chat_id" ))
    {
print ( "Unable to initialize robot" );
Return initialization failed ;
    }
 
//Send test message robot.Send message( "Robot connection successful!" );
 
//Send chart screenshot bot.SendChartScreenshot( "Current market conditions" );
 
Return initialization successful ;
}
 Boolean Send Message ( String Text); Boolean Send HTML Message ( String Text); Boolean Send Markdown Message ( String Text); Boolean Send Message Everyone ( String Text);
 Boolean SendTradeSignal(ENUM_SIGNAL_TYPE type, string symbol, double price); Boolean Send Opened Position( Oolong ticket, String symbol, ENUM_POSITION_TYPE type, Double volume, Double price); Boolean Send Closed Position( Oolong ticket, String symbol, Double profit, Double commission, Double exchange);
 Boolean send photo( string file path, string title); boolean send document( string file path, string title); boolean send chart screenshot(); boolean send chart screenshot( string title);
 Boolean Send Account Status(); Boolean Send Daily Report(); Boolean Send Weekly Report(); Boolean Send Monthly Report();
 Boolean value sends risk alert ( double drawdown percentage); Boolean value sends margin warning ( double margin level); Boolean value SendStopOutWarning();

The package contains a fully functional example EA that demonstrates:

 string message=" <B> bold text  B >\n";
message +=" <i> italic text  i >\n";
message +=" <code> fixed-width code  Code >\n";
message +=" <a link='http://example.com'> association  a > ";
bot.SendHTMLMessage(message);
 string message = "*bold text*\n" ;
message += "_italic text_\n" ;
Message += "`Fixed-width code`\n" ;
Message += "[Link](http://example.com)" ;
bot.SendMarkdownMessage(message);

The library includes comprehensive error handling:

The library is provided as-is for use in MetaTrader 5. Free for personal and commercial use.

Financial Blueprint <br/>Professional Trading Solutions

THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. Trading involves significant risk of loss and is not suitable for all investors. Past performance is not indicative of future results.

If you find this library useful, please rate it on the MQL5 Code Base!

Solution: 1. Tools → Options → Expert Advisors 2. ✓ Allow WebRequest for the listed URLs 3. Add: https://api.telegram.org 4. Restart MT5

Check: 1. Token correctness 2. Chat ID correctness 3. Internet connection 4. WebRequest settings

Possible reasons: 1. Exceeded API limit (30 messages/minute) 2. Invalid HTML format in message 3. Message too long (>4096 characters)

bot.SendTradeSignal(SIGNAL_BUY, "EUR/USD" , 1.1850 , 1.1800 , 1.1900 );
 string title=" <B> pointcut  B >\n";
Caption += "Currency pair: EURUSD\n";
Title += "Type: Purchase\n";
Title += "Price: 1.1850";
bot.SendChartScreenshot(title);
 bot.SendAccountStatus(); // Automatically send balance, net worth, margin, etc.
 // In EA's OnTimer()
if (timehour( timecurrent ()) == 23 && timeminute( timecurrent ()) == 0 )
{
    bot.SendDailyReport();
}
 Double retracement = calculate retracement(); // your calculation function
if (retracement > 20.0 ) // retracement is greater than 20% {
    bot.SendRiskAlert(retracement);
}
 [Opened position] ↑
===============
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 Exchange: - 0.50 Total: + 123.00 USD Time: 2024.01.15 14:45 ===============


 [Daily Report]
===============
Date: January 15, 2024 Account Summary----------------
Balance: $10,125.50 Equity: $10,250.00 Floating P&L: +$124.50 Trading Activity----------------
Today’s Transactions: 5
Today's results: +$250.00 Open positions: 2

Robot statistics----------------
Messages sent: 45
Send signal: 8
Success rate: 98.5%
===============



Attachment download

📎 TelegramBot.mqh (186.27 KB)

📎 testbot.mq5 (42.56 KB)

Source: MQL5 #63587

Refresh