Introduction

Hi interested reader,

great to see you here. Hopefully you entered this website because

  • you are generally a Metatrader user,
  • ideally a Metatrader user that does automatic trading or wants to share trading signals with other users and
  • in the best case you’re looking for a possibility to establish a communication channel between Metatrader and a messenger.

Does this hit the nail on the head? Than the following chapters may be very interesting for you. If you are at least a Metatrader user there is a little chance to get inspired from the idea of Metatrader chatting with you and vice versa 🙂 Have a look!

Why Telegram?

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 such a feature rich interface to start communication via bots. Until now the interface got mature, a lot more feature rich and is still growing. That is why Telegram was the choice to automate Metatrader Expert Advisors.

Introducing Telegram 4 MQL

Telegram 4 MQL is a .NET library that intends to bring all the possibilities from the well known Telegram messenger to Metatrader. With the help of the Telegram Bot feature you will be able to send and receive messages with ease right from your MQL code. 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 Telegram 4 MQL.

As you can see in this sketch Telegram 4 MQL acts like a middleware between Metatrader and the Telegram network. You can instruct your Expert Advisor to send a message and the Telegram network will deliver it to the users. On the other hand users are able to send messages to your Expert Advisors. Based on this messaging channel you can build your own business logic on top. In case of received messages that means you can execute specific MQL code depending on the received messages.

Why an external (managed) DLL?

Due to the limitations of native MQL like the missing support of real asynchronous operations and several C features that are missing in MQL, the decision was to use a higher level platform. Because Metatrader is developed with the focus towards the windows platform, Telegram 4 MQL is based upon .NET framework which offers a lot of possibilites for later implementation stages.

Impressions of Telegram 4 MQL in the wild

Sending plain Text Messages

Example picture showing the possibility to send text messages from Metatrader MQL to Telegram

If you would like to send signals to channels/groups/private chats, have a look at my blog post.

Sending Screenshots

The easiest way to send ad hoc information about a running Metatrader Expert Advisor -> Send the complete screen with all activities.

Example picture showing the possibility to send text screenshots from Metatrader MQL to Telegram

Sending Photos

Do you wish to send photos from an existing file? For example screenshots you took via MQL function chartscreenshot?

Example picture showing the possibility to send text photos from Metatrader MQL to Telegram

Sending Files

There are circumstances when it is useful to send files (for example logging information of Expert Advisors in .txt format or pictures with high resolution that would be minimized by Telegram).

Example picture showing the possibility to send text files from Metatrader MQL to Telegram

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 the Telegram4MQL function that fetches all messages send to your Bot (see the documentation provided), restrict permissions only to the ID of the user @SuperTrader within the call, extract the command “/stop” and force your Expert Advisor to stop all actities as a reaction to that.

A code based example is hosted on Github.

Quick Start

To get started immediatly read these posts: