CalendarEventById

Ottieni una descrizione dell'evento tramite il suo ID.

bool  CalendarEventById(
   ulong                event_id,     // ID evento
   MqlCalendarEvent&    event         // variabile per ricevere una descrizione dell'evento
   );

Parametri

event_id

[in]  Event ID.

event

[out] MqlCalendarEvent: è il tipo di variabile per ricevere una descrizione dell'evento.

Valore di ritorno

Restituisce true se ha successo, altrimenti - false. Per ottenere informazioni su un errore, chiamare la funzione GetLastError(). Possibili errori:

  • 4001 – ERR_INTERNAL_ERROR  (errore di runtime generale),
  • 5402 – ERR_CALENDAR_NO_DATA (Paese non trovato),
  • 5401 – ERR_CALENDAR_TIMEOUT (tempo limite della richiesta ecceduto).

Esempio:

//+------------------------------------------------------------------+
//| Funzione Start del programma Script                              |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- codice Paese per la Germania (ISO 3166-1 Alpha-2)
   string germany_code="DE";
//--- ottiene eventi Tedeschi
   MqlCalendarEvent events[];
   int events_count=CalendarEventByCountry(germany_code,events);
//--- mostra gli eventi Tedeschi nel Journal
   if(events_count>0)
    {
      PrintFormat("Germany events: %d",events_count);
      ArrayPrint(events);
     }
   else
    {
      PrintFormat("Impossibile ricevere eventi per il codice Paese %s, errore %d",
                  germany_code,GetLastError());
//--- completamento precoce script
      return;
     }
//--- ottiene la descrizione dell'ultimo evento dall'array events[]
   MqlCalendarEvent event;
   ulong event_id=events[events_count-1].id;
   if(CalendarEventById(event_id,event))
    {
      MqlCalendarCountry country; 
      CalendarCountryById(event.country_id,country);
      PrintFormat("Descrizione evento con event_id=%d ricevuto",event_id);
      PrintFormat("Paese: %s (country code = %d)",country.name,event.country_id);
      PrintFormat("Nome evento: %s",event.name);
      PrintFormat("Codice evento: %s",event.event_code);
      PrintFormat("Importanza evento: %s",EnumToString((ENUM_CALENDAR_EVENT_IMPORTANCE)event.importance));
      PrintFormat("Tipo di evento: %s",EnumToString((ENUM_CALENDAR_EVENT_TYPE)event.type));
      PrintFormat("Settore evento: %s",EnumToString((ENUM_CALENDAR_EVENT_SECTOR)event.sector));
      PrintFormat("Freuenza evento: %s",EnumToString((ENUM_CALENDAR_EVENT_FREQUENCY)event.frequency));
      PrintFormat("Modalità rilascio evento: %s",EnumToString((ENUM_CALENDAR_EVENT_TIMEMODE)event.time_mode));
      PrintFormat("Unità di misura evento: %s",EnumToString((ENUM_CALENDAR_EVENT_UNIT)event.unit));
      PrintFormat("Numero di cifre decimali: %d",event.digits);
      PrintFormat("Moltiplicatore evento: %s",EnumToString((ENUM_CALENDAR_EVENT_MULTIPLIER)event.multiplier));
      PrintFormat("URL sorgente: %s",event.source_url);
     }
   else
      PrintFormat("Impossibile ottenere la descrizione dell'evento per event_d =%s, errore %d",
                  event_id,GetLastError());
  }
/*
  Risultato:
  Eventi Tedeschi: 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
  Descrizione dell'evento con event_id = 276500003 ricevuto
  Paese: Germania (codice Paese = 276)
  Nome dell'evento: Markit PMI Composito
  Codice evento: markit-composite-pmi
   Importanza evento: CALENDAR_IMPORTANCE_MODERATE
   Tipo di evento: CALENDAR_TYPE_INDICATOR
   Settore evento: CALENDAR_SECTOR_BUSINESS
   Frequenza evento: CALENDAR_FREQUENCY_MONTH
   Modalità rilascio evento: CALENDAR_TIMEMODE_DATETIME
   Unità di misura evento: CALENDAR_UNIT_NONE
  Numero di posizioni decimali: 1
   Valore moltiplicatore: CALENDAR_MULTIPLIER_NONE
   URL sorgente: https://www.markiteconomics.com
*/

Guarda anche

CalendarEventByCountry, CalendarEventByCurrency, CalendarValueById