How to send alerts from Discord to MetaTrader 4/5

To send alerts from Discord to MetaTrader 4/5 you will need:

  1. Get the Discord read key
  2. Install Order Executer library to your MetaTrader 4/5
  3. Import alerts into your export

How to get a read key for the Discord

Step 1. Join our Discord Server

You can join using two ways:

Step 2. Start a conversation with Profit Robots Bot

Find Profit Robots Bot in the list of contacts on our server a send any message to it.

It should reply to you and give you a key (NOTE: the key is missing on the screenshot, but you will have it). 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 type "S" to get all your keys (you can have more than one key) on the main menu. To back to the previous menu level type "C" (Cancel).

Creating a channel key.

Each channel will have its own secret key. Follow the next steps to get that key.

Step 1. Type "A" in the "Manage" menu

The bot will reply to you with a brief description, a link to add a bot, and a list of available channels. You need to be the owner of the server in order to add a bot to the channel.

Step 2. If the required server not in the list of available servers then follow the link to add the bot

Select the server and push the "Authorize" button.

Step 3

Type "R" to refresh the list. The bot will print the updated list.

And select the channel by typing its index. You need a read key.

The bot will reply to you with a key.

How to read alerts in MetaTrader 4/5

You can get alerts by using AdvancedNotificationsLib. Do import that library by putting the next piece of code:

enum ServerType
   SelfHosted = 1, // Self-hosted
   WSS = 4, // (secured)
#import "AdvancedNotificationsLib.dll"
void AdvancedAlert(string key, string text, string instrument, string timeframe);
bool StartListener(string key, int serverType);
bool StopListener();
int ListenerStatus();
string GetNextMessage();

This library load alerts asynchronously. It cal load alerts for 1 key only.

Call StartListener in the initialization of an expert to start loading alerts for the specified key.

Before getting an alert check for the status by calling ListenerStatus. If the status is "LISTENER_STATUS_DISCONNECTED" then connect again.

Call the GetNextMessage in a loop. Each call will return a new alert. An empty string will be returned when there will be no more alerts.

Call StopListener in the deinitialization of an expert.

bool connect_sent = false;

void DoConnect()
   StartListener("You read key", WSS);
   connect_sent = true;

int OnInit()
   if (!IsDllsAllowed())
      Alert("Error: Dll calls must be allowed!");
      return INIT_FAILED;

   if (ListenerStatus() == LISTENER_STATUS_DISCONNECTED)

void OnDeinit(const int reason)
   connect_sent = false;

void OnTimer()
   if (!connect_sent && ListenerStatus() == LISTENER_STATUS_DISCONNECTED)
   string command = GetNextMessage();
   while (command != "")
      command = GetNextMessage();

You can use order_executer if you the one who sends these alerts into the channel. Just send alerts in this format. order_executer can parse this syntax and execute orders without any coding.