In order to send an alert from MetaTrader 4/5 to Discord you need:
You can join using two ways:
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).
You can regenerate any key. In order to do that you need:
The bot will generate a new key.
To delete the key you need to follow the same steps but type D instead of R. But only channel/group keys could be deleted.
You can send messages to Discord channels. Each channel will have its own secret key. Follow the next steps to get that key.
The bot will reply to you with a brief description, a link to add a bot and the list of available channels. You need to be an owner of the server in order to add a bot to the channel.
Select the server and push the Authorize button.
Type R to refresh the list. The bot will print the updated list.
And select the channel by typing its index
The bot will reply to you with a key.
Mention the bot on your server. The bot will detect that message and give you the key which you can use to post messages.
There are two types of channel keys:
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.
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);
#import
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)
{
Alert(message);
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