Please research MQL5 Network functionality — Documentation on MQL5: Network Functions (for example, WebRequest) .
Also, please learn to use the "Search" function before you post — https://www.mql5.com/en/search#!keyword=discord
It is very easy: type something (what you need) in the search area (top right corner of the page) and search.
- www.mql5.com
This simple function allows to send messages to Discord,... it can be used in any EA, all you need to enter is the message to send and the webhook from Discord... you also need to allow discord in the options.
void MessageToDiscord(string Message, string webhook) { int Trd; //reponse from sending message string JsonMessage = "{\"content\":\"" + Message +"\"}"; string headers = "Content-Type:application/json\r\n"; string response_header; char postfxa[],fbfxa[]; ResetLastError(); ArrayResize(postfxa,StringToCharArray(JsonMessage,postfxa,0,WHOLE_ARRAY,CP_UTF8)-1); Trd=WebRequest("POST",webhook,headers,500,postfxa,fbfxa,response_header); if(Trd==-1) { MessageBox("Go to Tools then Options and on the Expert Advisors tab add the URL for Discord", "Error", MB_ICONINFORMATION); } }
This simple function allows to send messages to Discord,... it can be used in any EA, all you need to enter is the message to send and the webhook from Discord... you also need to allow discord in the options.
Wonderful! This is exactly what I need, but I need to ask @Camilo Mora, I was wondering how do you send a screenshot basically an image element through MQL5 web request to discord?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone,
Does MQL5 has a functionality to send messages via Webhooks as in TradingView? This could allow any type of MQL5 information to be send to many different outlets (e.g. Discord).
I have found several pay apps, but this strikes me as a basic functionality, plus I would like to see the code, given the sensitive nature of the operation.
For instance, is there a stand-alone MQL5 function (Class) that takes as
Variables:
1) a webhook or channel, and
2) a Message string
and as a Function:
1) sends the Message to the channel.
Not necessarily an ea, but a class function, so it can be used in a single line of code by any EAs.