Loading...
 

Overview

 

Introduction

Telegram Logo  

Using the MQL Telegram module you're able to send and receive Telegram messages with ease right from your MQL code. See the impressions below. 


As you probably know, Telegram is a popular alternative to the big players on the market like WhatsApp, Facebook Messenger, Signal and further more. But Telegram was the first that offered a feature rich interface (the Telegram Bot API) to start communication via bots. That is what this module is utilizing. When talking about MQL code mainly Expert Advisors are meant. But of course every piece of code where libraries can be loaded is able to use MQL Telegram. For a full list of functions see

Impressions of this module in the wild

Sending plain Text Messages

MQL:

string resultOfSendText = SendText("-1001167825793", "Some text");

Result in a Telegram channel:

Screenshot from Telegram Desktop Client
Screenshot from Telegram Desktop Client

 

Sending Photos

string resultOfStartSendPhoto = StartSendPhoto("-1001167825793", "D:/pathToPhoto/photo.png");

Result in a Telegram channel:

Screenshot from Telegram Desktop Client
Screenshot from Telegram Desktop Client

This might be interesting if you wish to send photos from an existing file like screenshots that you generated via the MQL function chartscreenshot.

Receiving Messages

It is also possible to receive messages that were send to your bot. This way you can instruct your Expert Advisor to execute specific tasks based on the messages you provide.

Example? Say for instance you pick up your phone, open Telegram (your fictitious username is @SuperTrader) and send the following message to your Telegram Bot: "/stop" -> You intend to stop the Expert Advisor's activities.

Then all you need to do in your Expert Advisor is to call

string resultOfGetUpdates = GetUpdates();

Now you can inspect the messages that your bot received, maybe filter them (restrict permission to certain users) and extract commands etc. that you want to interpret.