Quickstart

All you need to get started is to

  • create a Telegram Bot (very easy) if you haven't already,
  • allow DLL import and WebRequests to Telegram API if you haven't already,
  • download the binaries from download section,
  • copy the binaries to Metatraders library directory and
    • usually a directory like C:\Users<USER>\AppData\Roaming\MetaQuotes\Terminal<ID>
  • import the DLLs functions in your MQL code like shown below:
#import "Telegram4Mql.dll"
   string TelegramSendTextAsync(string ApiKey, string ChatId, string ChatText);
   //...
#import

Then you can call them for example in your Expert Advisor like this:

void OnInit()
{
    string apikey = "11214xxxxxxxxxx";
    string chatid = "1417xxxxxxxx";
    Print(TelegramSendTextAsync(apikey, chatid, "test async")); // will print '0' if success 
}

Please be aware that there are versions for 32 bit and for 64 bit systems. Metatrader 4 is always 32 bit but when using Metatrader 5, the Metatrader installer chooses a specific architecture based on your host system.

Allow DLL Import and WebRequests

In order to call external libraries you have to explicitely allow this. Furthermore you need to allow outgoing web requests to the Telgram API:

option_dialogue_dll_webreq.png

Creating a Telegram Bot

If you do not already own such a bot, you can set one up in under 5 minutes. Take a quick tour through the Telegram Bot FAQ. The most important part is the API key, keep it secret. That even also means, that if you redistribute an EA in combination with Telegram 4 MQL you should't leave the hardcoded API key in you EA.