Discussion of article "How to create bots for Telegram in MQL5"

 

New article How to create bots for Telegram in MQL5 has been published:

This article contains step-by-step instructions for creating bots for Telegram in MQL5. This information may prove useful for users who wish to synchronize their trading robot with a mobile device. There are samples of bots in the article that provide trading signals, search for information on websites, send information about the account balance, quotes and screenshots of charts to you smart phone.

Telegram has three schemes of interaction between bots and users. First - private chats. Every user communicates with a bot independently from each other, as shown if Fig 3, by making requests and receiving replies.


bot and private chats

Fig.3.  Bot and private chats.


Users send messages to a bot. They are stored on the server for no longer than 24 hours, and are removed afterwards. A bot has time to request these messages and to respond to them. This is the main mode that our bots will be operating in.

Author: Andrey Voytenko

 

Interesting article!

Do the codes work on MT4?

 
Kodir Amanaliev:

Do the codes work on MT4?

Yes, try them.
 
Very interesting and useful article! Thank you!
 
Andrey Voytenko:
Yes, try it.

I tried Telegram_bot_EA on MT4. It installed normally. I entered the token in the settings. Added URL: https://api.telegram.org to the list of allowed addresses. At the beginning it worked fine after requesting 2-3 commands the Expert Advisor is automatically removed from the chart due to lack of memory....

log screen

 
Cool! Sleek and modern )
 

I thank readers for positive feedback.

The first joint tests revealed errors in the code, so I will post here an archive with corrections. It will be updated in the article soon.

Files:
telegram.zip  31 kb
 
New version of the codes.
Files:
telegram.zip  31 kb
 
Thank you very much, very useful material!
 
Thank you very much for the material. There is only one question: I can't configure sending messages to the channel. The error is "Bad Request". Token and channel name are correct. I can't understand what the problem is.
 
Dmitri Custurov:
Thank you very much for the material. There is only one question: I can't configure sending messages to the channel. The error is "Bad Request". Token and channel name are correct. I can't understand what the problem is.

BadRequest is a reaction to sending a message to a private channel. Actually, the developers originally planned to have bots work only with public channels.

But you can work with private channels by ID.

The scheme of getting ID is as follows:

  • Make the channel public, set username for it.
  • Add a bot to the channel as an administrator.

After clicking the link the channel ID will be displayed, remember it.

  • Make the channel private.

Channel ID does not change over time, so this scheme is quite workable.