Skip to content
NEXORA Money & AI

How to Create an MT5 Alert Tool With Popup and Push Notifications

October 2, 2026 · OYIN ADESOLA · 5 min read · Updated October 12, 2026
Cover graphic for the article: How to Create an MT5 Alert Tool With Popup and Push Notifications

Last checked: 12 October 2026. This guide draws on the MQL5 reference for Alert and SendNotification and on MetaQuotes’ help pages for terminal notification settings. Code is a teaching example; test on a demo account.

An alert tool watches the market so you do not have to. MetaTrader 5 can show a popup on your screen, play a sound and send a push notification to your phone. This guide builds an alert function that uses all three, stays inside the platform’s limits and fires only once per candle.

The three channels

  • Alert() opens a popup window in the terminal and writes to the Experts log.
  • PlaySound() plays a sound file from the terminal’s Sounds folder.
  • SendNotification() sends a push message to the MetaTrader mobile app.

Setting up push notifications

MetaQuotes explains that push notifications use a MetaQuotes ID, a unique identifier created when you install the mobile terminal. The ID identifies one installation on one device, not a person. Follow these steps:

  1. Install MetaTrader 5 on your phone and open Settings, then Messages. Note the MetaQuotes ID.
  2. On the desktop terminal open Tools, then Options, then the Notifications tab.
  3. Tick Enable Push Notifications and paste the ID. Several IDs can be entered, separated by commas.
  4. Press Test. A test message should arrive on your phone.

The limits you must respect

The MQL5 reference states that SendNotification has strict limits: no more than 2 calls per second and no more than 10 calls per minute. It adds that frequency is monitored dynamically and the function can be disabled if you break the rule. A message must not exceed 255 characters. The function returns false on failure, and GetLastError can return codes such as 4517 for wrong settings or 4518 for calls that are too frequent. The reference also says SendNotification does not run in the Strategy Tester, so you cannot test push messages by backtesting.

Summary graphic listing the main sections of: How to Create an MT5 Alert Tool With Popup and Push Notifications

Design rule: one alert per candle

An alert that fires on every tick will hit the rate limit in seconds and may get notifications switched off. A safer design stores the time of the bar that last produced an alert and ignores repeats. This also stops the same signal being announced many times while price hovers around a level.

The alert helper

input bool InpPopup = true;
input bool InpSound = true;
input bool InpPush  = true;

datetime g_lastAlertBar = 0;
datetime g_lastPush     = 0;

// Call with the text and the time of the candle that produced the signal.
void RaiseAlert(const string text, const datetime barTime)
  {
   if(barTime == g_lastAlertBar) return;      // already alerted for this candle
   g_lastAlertBar = barTime;

   string msg = _Symbol + " " + EnumToString(_Period) + ": " + text;
   if(StringLen(msg) > 250) msg = StringSubstr(msg, 0, 250);

   if(InpPopup) Alert(msg);
   if(InpSound) PlaySound("alert.wav");

   if(InpPush)
     {
      // simple guard: at most one push every 10 seconds
      if(TimeLocal() - g_lastPush >= 10)
        {
         ResetLastError();
         if(!SendNotification(msg))
            PrintFormat("Push failed, error %d", GetLastError());
         else
            g_lastPush = TimeLocal();
        }
     }
  }

Using it in an indicator

Inside OnCalculate, decide the signal using the last closed bar and then call RaiseAlert with that bar’s time. For example, after computing a BUY state from the earlier article in this series, call RaiseAlert(“BUY signal”, time[rates_total – 2]). Because the bar time is the key, the alert fires once when the candle closes and stays silent until the next candle.

Common reasons alerts do not arrive

  • The MetaQuotes ID is mistyped or belongs to a different install. Use the Test button.
  • Push is disabled in the Options window.
  • The phone app has notifications blocked by the operating system or battery saver.
  • The code ran in the Strategy Tester, where push notifications are not sent.
  • Too many messages were sent and the platform blocked the function.

Be careful with what the alert says

Push messages travel through MetaQuotes’ servers. Do not put account numbers, balances or passwords in the text. Keep messages short and factual, such as symbol, timeframe and state.

Step by step: a first working alert

  1. Create an Expert Advisor or indicator in MetaEditor and paste the helper above it.
  2. Add a line that calls RaiseAlert(“test alert”, iTime(_Symbol, _Period, 0)) inside OnInit or on the first tick. Because the time key is the current bar, the alert fires once, which proves the channels work.
  3. Run it on a demo chart. You should see a popup, hear a sound and receive a push message on your phone within a few seconds.
  4. Remove the test line and wire the helper to your real signal.

Choosing sound files

PlaySound plays files from the Sounds folder inside the terminal’s data folder. The default alert.wav is installed with the terminal. You can add your own short WAV files there and refer to them by file name. Keep sounds short, because a long one can overlap with the next. If you work in a shared space, make the sound optional, which is why the code uses an input switch.

Alerts for several conditions

If one tool watches several conditions, one shared timestamp is not enough, because a BUY alert on a candle would block a different alert on the same candle. Store one last-alert time per condition, for example in an array indexed by an alert type number. That way each type fires once per candle and they do not suppress each other. Also include the condition name in the message so you can tell them apart on a phone’s lock screen.

What we could not confirm

  • Delivery time. It depends on your connection, MetaQuotes’ service and your phone, and no delivery guarantee is published.
  • Whether the rate limits have changed in the newest build. Check the current MQL5 reference.

Frequently asked questions

Can I send email too? Yes. SendMail exists, but you must configure the Email tab in Options first.

Why does Alert show nothing in the tester? Visual testing can behave differently from live trading. Test alerts on a live demo chart.

Key takeaways

Configure the MetaQuotes ID, respect the two-per-second and ten-per-minute limits, key every alert to a candle time and keep messages short.

Sources checked

  • MQL5 Reference and MQL5 Book, “Sending push notifications”, mql5.com
  • MetaTrader help, “Client Terminal Settings: Notifications”, metatrader4.com help pages

Educational content only — not financial advice. Income and savings results vary and are never guaranteed. How we write

Enjoyed this story?

Get the best stories delivered weekly.

Leave a Reply

Your email address will not be published. Required fields are marked *

Share with