Why Automated Alerts Matter in MetaTrader
Staring at charts all day is neither sustainable nor efficient. MetaTrader 4 and 5 offer a robust alert system that can notify you via on-screen popups, email, or push notifications straight to your smartphone. Whether you use custom indicators, Expert Advisors (EAs), or built-in tools, mastering alerts means you never miss a critical price action or strategy trigger again.
In this guide, you will learn to set up every type of alert in MT4 and MT5, from basic price alarms to MQL4/MQL5 SendNotification() calls. We cover the exact menu paths, configuration steps, and code snippets you need to get push notifications working reliably on your mobile device. The difference between a good trading setup and a great one often comes down to how quickly you can react to market events — automated notifications eliminate the delay of manual monitoring.
Prerequisites
- MetaTrader 4 or 5 installed on your desktop (Windows). Version 1340+ for MT4, 3050+ for MT5 recommended. Check your build via Help → About.
- A live or demo trading account logged into the terminal. Push notifications work with both account types.
- MetaTrader mobile app (iOS or Android) installed on your smartphone — version 4.0+ for best compatibility.
- An email account for SMTP configuration (Gmail works well, but any SMTP-compatible provider like Outlook or Yahoo will do).
- Basic familiarity with the MetaEditor IDE for MQL code examples — you'll need to compile
.mq4or.mq5files.
Step-by-Step Alert Configuration
1. Enable Push Notifications in MT4/MT5
Push notifications send alerts directly to your MetaTrader mobile app without relying on email delays. This is the fastest and most reliable method, typically delivering within 1–5 seconds.
- Open MetaTrader and go to Tools → Options (or press
Ctrl+O). - Click the Notifications tab.
- Check Enable Push Notifications.
- Enter your MetaQuotes ID. To find this: open the MT4/MT5 mobile app, tap Settings → Chat and Messages → Account, and copy the ID shown (e.g.,
51432-12345). The ID is unique per device and account combination. - Click OK to save.
MT5 difference: The tab is labeled identically. If using MT5 build 2000+, you may also see a Test button — use it to verify connectivity immediately. For MT4 builds before 1340, the Notifications tab may not exist; update your terminal.
2. Configure Email Alerts (Alternative)
Email alerts work as a fallback, but require an SMTP server. Here’s how to set up Gmail:
- Go to Tools → Options → Email tab.
- Fill in the fields as follows (example uses Gmail):
| Field | Value | Notes |
|---|---|---|
| SMTP server | smtp.gmail.com | No trailing slash or port |
| Port | 465 | SSL required; some use 587 with TLS |
| Login | [email protected] | Full Gmail address |
| Password | App password | Not your regular password; generate from Google Account → Security → App passwords |
| From | [email protected] | Must match login |
| To | [email protected] | Can be any email address |
- Click OK. Test by sending a simple email from the MT4/MT5 Test button (if available) or by running an EA that calls
SendMail().
Edge case: If you use Outlook.com, the SMTP server is smtp-mail.outlook.com on port 587 with TLS. For Yahoo, it's smtp.mail.yahoo.com on port 465. Always generate an app-specific password if 2FA is enabled on your email account.
3. Set Up Alerts from the Terminal Interface
You can create alerts directly on any chart without coding:
- Right-click on a chart → select Trading → Alert (or press
Ctrl+Alt+A). - In the Alert window, configure:
- Signal: Choose from Price, Time, Indicator, or Custom.
- Condition: For price alerts, pick Bid >, Ask <, etc., and enter the level. For time alerts, set a specific date/time.
- Action: Check Sound, File, Email, or Notification (push). You can select multiple actions simultaneously.
- Expiration: Set a date/time or leave blank for indefinite. Useful for one-time events like news announcements.
- Click OK. A small alarm bell icon appears on the chart; double-click it to edit or right-click to delete.
Pro tip: For indicator-based alerts (e.g., RSI crossing 30), you must first attach the indicator to the chart, then create an alert referencing that indicator line. The alert dialog will list all indicator buffers attached to the chart — select the correct one (e.g., RSI's main line is buffer 0).
4. Add Push Notifications to Custom EAs and Indicators
The real power comes from adding push alerts to your MQL4/MQL5 code. Use the SendNotification() function. This function sends a string message directly to your mobile device via the MetaQuotes push notification service.
MQL4 Example (EA or custom indicator):
//+------------------------------------------------------------------+
//| Alert when price crosses above a moving average |
//+------------------------------------------------------------------+
void OnTick()
{
double ma = iMA(_Symbol, _Period, 14, 0, MODE_SMA, PRICE_CLOSE, 0);
double bid = Bid;
static bool wasBelow = true;
if(bid > ma && wasBelow)
{
string msg = StringFormat("%s: Price %.5f crossed above MA %.5f",
_Symbol, bid, ma);
SendNotification(msg); // Push to phone
Alert(msg); // On-screen popup
wasBelow = false;
}
if(bid <= ma) wasBelow = true;
}
MQL5 equivalent uses the same SendNotification() function. The data type for bid is double and you must call SymbolInfoDouble():
double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
double ma = iMA(_Symbol, _Period, 14, 0, MODE_SMA, PRICE_CLOSE, 0);
Important: SendNotification() only works if push notifications are enabled in Tools → Options → Notifications. It returns true on success; check with if(!SendNotification(msg)) Print("Notification failed: ", GetLastError());. Common error codes include 4108 (notification not enabled) and 4109 (too many requests).
5. Test Your Push Notification Setup
- Ensure your mobile device has the MetaTrader app installed and is logged into the same account. The app must be running in the background or foreground.
- On desktop, go to Tools → Options → Notifications and click Test (MT5 build 2000+). If no test button exists, attach a simple EA that calls
SendNotification("Test alert from MT4/5")once. You can create a one-shot EA by placing the call inOnInit()and immediately removing it. - Check your phone within 10–30 seconds. If no alert appears, verify the MetaQuotes ID and that mobile notifications are enabled in phone settings (iOS: Settings → Notifications → MetaTrader; Android: Settings → Apps → MetaTrader → Notifications).
Troubleshooting test failures: If the test button returns "Error" immediately, your MetaQuotes ID may be incorrect. Re-copy it from the mobile app — IDs are case-sensitive and include the dash. Also check that the terminal is connected to the internet — offline terminals cannot send push notifications.
Tips and Best Practices from Experience
- Use push notifications over email. Email alerts can be delayed by 30 seconds to several minutes due to SMTP queuing. Push notifications are near-instant, typically under 5 seconds.
- Keep notification messages short. The mobile app truncates long messages to around 255 characters. Include only symbol, price, and signal name. Example: "EURUSD: 1.1050 above MA 1.1020" is ideal.
- Avoid alert spam. Use state flags (like the
wasBelowboolean in the example) to prevent repeated alerts on the same bar. Without this, your phone will buzz endlessly on every tick. - Rate limit your alerts. MetaTrader may throttle
SendNotification()if called more than once per second. Add aSleep(1000)or use a timestamp check to ensure at least 1 second between calls. Excessive calls can temporarily ban your MetaQuotes ID. - For VPS setups, ensure the VPS firewall allows outbound connections on port 443 (HTTPS) — push notifications use encrypted HTTP. Also verify that the terminal is running 24/7 — if the VPS restarts, the terminal must auto-launch.
- Backup your MetaQuotes ID. If you reinstall the mobile app, the ID changes. Keep a note in a password manager. Write it down physically as a fallback.
- Use multiple notification channels for critical alerts. Configure both push and email for the same event — if one fails, the other may still reach you.
Common Mistakes and Troubleshooting
| Issue | Cause | Fix |
|---|






