{
  "id": 16859081,
  "title": "Sending push notifications from an MQL5 EA without getting them switched off",
  "url": "https://urgent.news/2026/10/28/sending-push-notifications-from-an-mql5-ea-without-getting-them",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-28T06:30:35.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/omaisali/sending-push-notifications-from-an-mql5-ea-without-getting-them-switched-off-11h2"
  },
  "original_language": "en",
  "account": "Push notifications from Expert Advisors (EAs) provide a convenient way to stay informed about the EA's activities while away from the MetaTrader terminal. However, sending too many notifications can result in the terminal disabling the function, leaving you without alerts when they are most needed. This tutorial presents a solution that respects the terminal's limits while ensuring notifications are still sent and logged appropriately.\n\nThe key rules to follow are:\n1. The message length cannot exceed 255 characters.\n2. No more than 2 calls per second, and no more than 10 calls per minute.\n3. The terminal monitors these limits dynamically and can disable the function if the limits are exceeded.\n4. SendNotification() does not work in the Strategy Tester.\n5. Notifications must be enabled in the terminal, with your MetaQuotes ID entered under Tools, Options, Notifications.\n6. You can check the notification settings from your code using TerminalInfoInteger(TERMINAL_NOTIFICATIONS_ENABLED).\n\nTo implement a notifier that adheres to these rules, follow these steps:\n1. Create a queue to store messages and an array to keep track of sent messages.\n2. Define a limit for the number of messages per minute and the maximum queue size.\n3. Implement a function to check if notifications are available based on the EA's type (tester or live).\n4. Create a function called Notify() that takes a text message and an optional deduplication time parameter. This function checks if notifications are available, prevents duplicate messages within a specified time frame, formats the message, ensures it does not exceed 255 characters, and adds it to the queue if the size limit allows.\n5. Implement a function called FlushNotifications() that processes the queue by sending messages at a safe pace, respecting the per-second and per-minute limits. It also removes stale messages older than 60 seconds and retries sending messages if the initial attempt fails due to specific error codes.\n6. Call FlushNotifications() from a one-second timer to ensure notifications are sent at a controlled pace.\n7. Use appropriate triggers to initiate notifications, such as position changes, trade rejections, risk rule violations, connection issues, EA removal, or terminal closure.\n\nBy following this design, you can effectively manage the notification flow from your EA, ensuring that critical alerts are sent while staying within the terminal's limits. The notifier logs all messages while delivering timely notifications on your phone, allowing you to stay informed about your EA's activities without being overwhelmed by excessive alerts.",
  "summary": "A push notification to your phone is the simplest way to know what an Expert Advisor is doing while you are away from the terminal. MQL5 has one function for it, SendNotification(), and most EAs call it directly wherever something interesting happens. That works until the day something goes wrong. A disconnect, a loop of rejected orders or a burst of partial fills makes the EA call…",
  "key_points": [
    "Message length limited to 255 characters",
    "Max 2 calls per second, 10 calls per minute",
    "Terminal dynamically monitors limits"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}