Watch how to download trading robots for free
Find us on Facebook!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Libraries

Telegram integration made easy. - library for MetaTrader 5

Views:
256
Rating:
(1)
Published:
2025.03.02 04:26
\MQL5\Include\
Telegram.mqh (1.35 KB) view
\MQL5\Experts\
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

This Telegram module enables communication with Telegram by sending messages via the Telegram Bot API.

The function SendMessageToTelegram takes:

  1. a message, a chat ID, and a bot token as parameters to construct a JSON payload, 
  2. and sends it using an HTTP POST request to the Telegram API.

It uses the WebRequest function to make the request, with a timeout of 5000 milliseconds. If the request is successful (HTTP 200 response), it prints a confirmation message; otherwise, it prints an error message along with the response details.

Application Examples

  • Sending Signal Alerts
  • Other Communication Tasks

Below is an example demonstrating how to use the Telegram.mqh module in an Expert Advisor (EA). I have developed a simple testing EA that sends a greeting message to Telegram upon initialization.

When integrating Telegram messaging into an EA, three key steps are essential:

1. Include the Telegram Module

  • #include <Telegram.mqh>: Imports the module that provides the SendMessageToTelegram function.

2. Declare Telegram Credentials

  • botToken: Input parameter to store your Telegram bot token.
  • chatId: Input parameter to store your Telegram chat ID.

3. Send a Telegram Message

  • Define Message: Create a greeting message string.
  • Function Call: Use SendMessageToTelegram(message, chatId, botToken) within the OnInit() function.
  • Feedback Handling: Print messages indicating success or failure based on the HTTP response.

TelegramSendTesting

The results in the Experts log from the image above show an attempt to send a message to Telegram, which failed due to incorrect credentials.



Time To Close v1.01 - MT5 Time To Close v1.01 - MT5

Time to candle Close. Dynamic text colours. Optimised for back-testing.

Multiple EA Tracking with a Magic Number Based Profit and Loss Live Dashboard in MQL5 Multiple EA Tracking with a Magic Number Based Profit and Loss Live Dashboard in MQL5

Whether you’re running multiple trading robots simultaneously or just one sophisticated strategy, keeping track of each Expert Advisor’s performance can be surprisingly time-consuming. MetaTrader 5 (MT5) conveniently displays orders and positions in its “Toolbox,” but when numerous robots share the same account, it becomes harder to know which EA is generating your profits—or losses. A single account might have dozens or hundreds of trades, each opened by different EAs, making it difficult to separate the results of one robot from another.

Autoscaling Zigzag Autoscaling Zigzag

A zigzag indicator that uses a single input to adjust the step size for detecting wave direction changes

Fibonacci ZigZag Fibonacci ZigZag

Zig Zag indicator that relies only on a minimum % of retracement to each previous wave , and optionally , being bigger than a specific size measured in atr units.