[FX581 Original] MT4 development skills N ways to send notifications

MT4 indicators, EA discussion group
fx58

In the process of developing our own systems, especially when developing indicators that give arrow signals, there is often a need for notifications. Whether it is to make a sound to remind traders or to remind me when I am not in front of the computer or even outdoors, these needs are always very important to us.

So how can we promptly prompt users of trading signals that appear? Today, the editor will introduce several methods to you, each of which has its own advantages and disadvantages, and is only suitable for use in specific demand environments.

1. Make a sound.

Among the built-in functions of MT4, there is a function (PlaySound) that can play audio in wav format. Its function is to play sound. The parameter is the file name of the sound. The sample code is as follows:

if (the condition for signaling is met)

{

   PlaySound("alert.wav");

}

         alert.wav is the sound file that comes with the MT4 system. We use this function to play the sound. The rest only needs to connect the computer to the speaker and turn up the sound. This method is the simplest, but it is only suitable for use in an environment where people are in a room.

2. Send email.

The second method introduced to everyone is to use the email sending function of MT4 as a notification. First of all, we need to configure the mail settings. In the MT4 menu, select Tools -> Options


dachshund

In the dialog that opens, select the Email tab

dachshund

Check the Enable checkbox and enter the following:

 (1) SMTP server. SMTP is the abbreviation of Simple Mail Transfer Protocol (Simple Mail Transfer Protocol). Now we send emails through the SMTP server, so if we want to send emails, we need to specify the address and port number of the SMTP server (the middle uses separated by colons), taking 163 mailbox as an example, you should fill in: smtp.163.com:465.

(2) Email login account. This item is to fill in the sender's email address.

(3) Email password. The password of the sender's mailbox.

(4) The sender. You can fill in a name or directly fill in the email address of the sender for this item.

(5) Recipients. Fill in the recipient's email address.

After filling in, click Test to see if you can receive an email, if there is no problem, click OK, and the configuration is complete.

In the second step, we call the function of sending emails that comes with MT4 in the code to send emails. The sample code is as follows:

      if (the condition for signaling is met)

{

   SendMail("The title of the mail to be sent","Mail content");

}

In the last step, we install an APP on the mobile phone to receive emails. When there are new emails, the mobile phone will have a reminder, so that we can receive notifications of transaction signals even when we are outside.

3. Send text messages.

This method requires certain program development capabilities and is suitable for professional developers. The general idea is to develop a program for sending text messages and deploy it on a website. When a transaction signal occurs, send an HTTP request to the server, so that a text message is sent to our mobile phone to realize the notification.

In the first step, we need to configure the domain name for sending network requests in MT4. For security reasons, when MT4 sends a network request, domain name information must be configured in the software so that the request can be sent successfully. The specific operation is as follows:

Still select Tools->Options in the menu, then select the Expert Advisor tab:

dachshund

Tick ​​Allow WebRequest for the listed URLs, and add your own web domain name below.

The second step is to visit your own website to send SMS:

if (the condition for signaling is met)

{

   char post[],result[];

   string headers;

   int ret = WebRequest("GET","your server address",NULL,NULL,5000,post,0,result,headers);

   if(ret == -1)

   {

      // access error

   }

   else

   {

      string response = CharArrayToString(result);//response is the information returned by the server

   }

}

This article is to introduce the development of MT4, how to send SMS is not within the scope of this article. At present, the SMS platform can purchase Alibaba Cloud and other related services.

This method is the most complicated method of sending notifications, but it is more flexible and can implement a set of signal services for multiple customers. If your company provides various trading auxiliary services for trading customers, then this method is undoubtedly the most good solution.

4. MT4 APP notification.

Use the notification function (SendNotification) of MT4 to send the message to the mobile terminal. I believe that most developers are unfamiliar with this function. In fact, it uses the community function of MetaQuotes to send messages. This function first needs to register an account in the community (MQL5.community), and make corresponding settings in the MT4 software. The setting method is as follows,

In the menu select Tools->Options and select the Community tab:

dachshund

Fill in your community account and log in.

Write the following code in the code:

if (the condition for signaling is met)

{

   SendNotification("Content to be sent");

}

At the same time, install the MT4 software on the mobile phone and log in (the PC side and APP side of MT4 must be on the same platform) to realize the push notification of receiving signals.

The above four methods correspond to different situations. If you are watching the market at home or in the office, you can use the method of playing sound to remind you that there is a new trading signal. If you go out, you need to use the following methods. We recommend the last method. The development setting is relatively simple, and ordinary traders can also easily set it up.

Copyright reserved to the author

Last updated: 08/22/2023 13:59

378 Upvotes
Comment
Add
Original
Related questions
About Us User AgreementPrivacy PolicyRisk DisclosurePartner Program AgreementCommunity Guidelines Help Center Feedback
App Store Android

Risk Disclosure

Trading in financial instruments involves high risks including the risk of losing some, or all, of your investment amount, and may not be suitable for all investors. Any opinions, chats, messages, news, research, analyses, prices, or other information contained on this Website are provided as general market information for educational and entertainment purposes only, and do not constitute investment advice. Opinions, market data, recommendations or any other content is subject to change at any time without notice. Trading.live shall not be liable for any loss or damage which may arise directly or indirectly from use of or reliance on such information.

© 2024 Tradinglive Limited. All Rights Reserved.