CalendarEventById

Obtiene la descripción del evento según su identificador.

bool  CalendarEventById(
   ulong                event_id,     // identificador del evento
   MqlCalendarEvent&    event         // variable para obtener la descripción del evento
   );

Parámetros

event_id

[in]  Identificador del evento.

event

[out]  Variable del tipo MqlCalendarEvent para obtener la descripción del evento.

Valor retornado

Retorna true en el caso de éxito, de lo contrario, false. Para obtener información sobre el error, necesitamos llamar la función GetLastError(). Posibles errores:

  • 4001 — ERR_INTERNAL_ERROR  (error general del sistema de ejecución),
  • 5402 — ERR_CALENDAR_NO_DATA (el país no ha sido encontrado),
  • 5401 — ERR_CALENDAR_TIMEOUT (se ha superado el límite de solicitud por tiempo).

Ejemplo:

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- código del país para Alemania según el estándar ISO 3166-1 Alpha-2
   string germany_code="DE";
//--- obtenemos los eventos para Alemania
   MqlCalendarEvent events[];
   int events_count=CalendarEventByCountry(germany_code,events);
//--- mostramos los eventos de Alemania en el Registro
   if(events_count>0)
     {
      PrintFormat("Eventos para Alemania: %d",events_count);
      ArrayPrint(events);
     }
   else
     {
      PrintFormat("No se ha logrado obtener los eventos para el código de país %s, error %d",
                  germany_code,GetLastError());
      //--- finalizando el script de manera anticipada 
      return;
     }
//--- obtenemos la descripción del último evento de la matriz events[]
   MqlCalendarEvent event;
   ulong event_id=events[events_count-1].id;
   if(CalendarEventById(event_id,event))
     {
      MqlCalendarCountry country; 
      CalendarCountryById(event.country_id,country);
      PrintFormat("Se ha obtenido la descripción del evento de event_id=%d",event_id);
      PrintFormat("País: %s (código del país = %d)",country.name,event.country_id);
      PrintFormat("Nombre del evento: %s",event.name);
      PrintFormat("Código del evento: %s",event.event_code);
      PrintFormat("Importancia del evento: %s",EnumToString((ENUM_CALENDAR_EVENT_IMPORTANCE)event.importance));
      PrintFormat("Tipo de evento: %s",EnumToString((ENUM_CALENDAR_EVENT_TYPE)event.type));
      PrintFormat("Sector del evento: %s",EnumToString((ENUM_CALENDAR_EVENT_SECTOR)event.sector));
      PrintFormat("Periodicidad del evento: %s",EnumToString((ENUM_CALENDAR_EVENT_FREQUENCY)event.frequency));
      PrintFormat("Modo de salida del evento: %s",EnumToString((ENUM_CALENDAR_EVENT_TIMEMODE)event.time_mode));
      PrintFormat("Unidad de medición del valor: %s",EnumToString((ENUM_CALENDAR_EVENT_UNIT)event.unit));
      PrintFormat("Número de dígitos decimales: %d",event.digits);
      PrintFormat("Multiplicador del valor: %s",EnumToString((ENUM_CALENDAR_EVENT_MULTIPLIER)event.multiplier));
      PrintFormat("URL de la fuente: %s",event.source_url);
     }
   else
      PrintFormat("No se ha logrado obtener la descripción del evento para event_d=%s, error %d",
                  event_id,GetLastError());
  }
/*
  Resultado:
  Eventos para Alemania: 50
             [id] [type] [sector] [frequency] [time_mode] [country_id] [unit] [importance] [multiplier] [digits]                                [source_url]                       [event_code]                             [name] [reserved]
   [ 0] 276010001      1        6           2           0          276      1            1            0        1 "https://www.destatis.de/EN/Homepage.html"  "exports-mm"                       "Exports m/m"                               0
   [ 1] 276010002      1        6           2           0          276      1            1            0        1 "https://www.destatis.de/EN/Homepage.html"  "imports-mm"                       "Imports m/m"                               0
   [ 2] 276010003      1        4           2           0          276      1            1            0        1 "https://www.destatis.de/EN/Homepage.html"  "import-price-index-mm"            "Import Price Index m/m"                    0
   [ 3] 276010004      1        4           2           0          276      1            1            0        1 "https://www.destatis.de/EN/Homepage.html"  "import-price-index-yy"            "Import Price Index y/y"                    0
   ....
   [47] 276500001      1        8           2           0          276      0            2            0        1 "https://www.markiteconomics.com"           "markit-manufacturing-pmi"         "Markit Manufacturing PMI"                  0
   [48] 276500002      1        8           2           0          276      0            2            0        1 "https://www.markiteconomics.com"           "markit-services-pmi"              "Markit Services PMI"                       0
   [49] 276500003      1        8           2           0          276      0            2            0        1 "https://www.markiteconomics.com"           "markit-composite-pmi"             "Markit Composite PMI"                      0
  Obtenidas descripciones del evento de event_id=276500003
  País: Germany (код страны = 276)
  Nombre del evento: Markit Composite PMI
  Código del evento: markit-composite-pmi
   Importancia del evento: CALENDAR_IMPORTANCE_MODERATE
   Tipo de evento: CALENDAR_TYPE_INDICATOR
   Sector del evento: CALENDAR_SECTOR_BUSINESS
   Periodicidad del evento: CALENDAR_FREQUENCY_MONTH
   Modo de salida del evento: CALENDAR_TIMEMODE_DATETIME
   Unidad de medición del valor: CALENDAR_UNIT_NONE
  Número de dígitos decimales: 1
   Multiplicador del valor: CALENDAR_MULTIPLIER_NONE
   URL de la fuente: https://www.markiteconomics.com
*/

Ver también

CalendarEventByCountry, CalendarEventByCurrency, CalendarValueById