SendNotification

Esta función envía avisos a los terminales móviles cuyos MetaQuotes ID han sido indicados en la ventana de ajustes en la pestaña "Notificaciones".

bool  SendNotification(
   string  text          // texto del mensaje
   );

Parámetros

text

[in]   Texto del mensaje en la notificación. La longitud del mensaje no puede superar 255 caracteres.

Valor devuelto

Devuelve true si la notificación ha sido enviada con éxito desde el terminal; de lo contrario, devuelve false. Durante la comprobación tras el fallo del envío, GetLastError() puede mostrar uno de los siguientes errores:

  • 4515 — ERR_NOTIFICATION_SEND_FAILED,
  • 4516 — ERR_NOTIFICATION_WRONG_PARAMETER,
  • 4517 — ERR_NOTIFICATION_WRONG_SETTINGS,
  • 4518 — ERR_NOTIFICATION_TOO_FREQUENT.

Nota

Para la función SendNotification() existen unas estrictas limitaciones de uso: no más de dos llamadas al segundo y no más de 10 llamadas al minuto. La frecuencia de uso se controla de forma dinámica, y la función puede ser bloqueada si tiene lugar la infracción de estas condiciones.

Durante el trabajo en el Probador de Estrategias la función SendNotification() no se ejecuta.

Ejemplo:

//+------------------------------------------------------------------+
//|                                             SendNotification.mq5 |
//|                                  Copyright 2024, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2024, MetaQuotes Ltd."
#property link      "https://www.mql5.com
#property version     "1.00"
 
#define   MESSAGE   "Test Message"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart(void)
  {
//--- comprobamos el permiso de envío de notificaciones en el terminal
   if(!TerminalInfoInteger(TERMINAL_NOTIFICATIONS_ENABLED))
     {
      Print("Error. The client terminal does not have permission to send notifications");
      return;
     }
//--- enviamos una notificación
   ResetLastError();
   if(!SendNotification(MESSAGE))
      Print("SendNotification() failed. Error ",GetLastError());
  }