How to send alerts from MetaTrader 4/5 to Telegram

In order to send an alert from MetaTrader 4/5 to Telegram you need:

  1. Get Telegram key from ProfitRobots bot
  2. Install Notifications library to your MetaTrader 4/5
  3. Modify your indicator/expert

How to get a secret key for the Telegram

Step 1. Find Profit Robots Bot

Use this link or just search for "Profit Robots Bot". There are some fake bots, so make sure that you are using the real one (like shown on the screenshot).

Step 2. Start a conversation.

Start a conversation with Profit Robots Bot. It should reply to you and give you a key. This is your personal key. All messages for that key will be forwarded by the bot into your private dialog with the bot.

You can always use the "Show my keys" buttons to get all your keys (you can have more than one key).

Generate a new key or delete it

You can regenerate any key. In order to do that you need:

Step 1. Push the "Manage keys" button

Step 2. Select a key you want to regenerate by clicking on its index or typing "/number"

Step 3. Push "Regenerate"

The bot will generate a new key.

To delete key you need to follow the same steps but use the "Delete" button instead of "Regenerate". But only channel/group keys could be deleted.

Creating a channel or group key.

You can send messages to Telegram channels/groups. Each channel or group will have its own secret key. Follow the next steps to get that key.

Step 1. Push the "+ Channel key" button.

The bot will send you a brief instruction and secret code to verify the channel or group.

Step 2. Add Profit Robots Bot to your channel/group or char as an administrator

Click on your channel/group name.

Telegram will show you a window with the information about your channel. Push 3 dots to get the menu and select "Manage group" or "Manage channel".

In the "Edit group" window click on "Administrators".

Push the "Add administrator" button.

Search for "@@profit_robots_bot" and select the Profit Robots Bot.

Click "OK".

For a group, you may unselect all permissions and click the "Save" button. Close all windows.

The bot will automatically detect addition to the new group and will give you the key.

For a channel leave the "Post messages" permission for the bot.

Close all windows and post the verification code into your channel from Step 1. The "write key" allows you to post messages into the channel. The "read key" allows you to get keys posted into this channel from MetaTrader 4/5 and FXTS2.

The bot should detect the verification code and give you the key for that channel. You can delete the verification code from your channel now.

How to install the Notification library into your MetaTrader 4/5

Run ProfitRobots installer. It'll show you all MetaTrader terminals installed on your PC.

Select the one you need, select the Notifications options and click "Install".

Modify the code of indicator/expert to support a new type of alerts

This manual is for developers. If you are not a developer then consider hiring one. You can find the developer on Upwork or use a free development service like FXCodeBase.

You need to have an option for the key received above.

input string   advanced_key             = ""; // Advanced alert key

Or you can hardcode it as well.

Import of the Notifications library. You can do that using this piece of code

#import "AdvancedNotificationsLib.dll"
void AdvancedAlert(string key, string text, string instrument, string timeframe);

Find a place in the code where the alerts are sent. Usually, it's an Alert, PlaySound, or SendNotification function calls. Add call of AdvancedAlert() function:

if (signal)
    AdvancedAlert(advanced_key, message, "", "");

That's it. Just do not forget to allow DLL imports in the indicator/expert parameters.

Or you can use our templates for MT4 and MT5 if you are coding it from scratch.

You can find a real-world example here: MT4 Engulfing Pattern with Telegram alerts