CalendarEventById

根据ID获得事件描述。

bool  CalendarEventById(

   ulong                event_id,     // 事件ID

   MqlCalendarEvent&    event         // 用于接收事件描述的变量

   );

参数

event_id

[in]  事件ID。

event

[out] MqlCalendarEvent类型变量,用于接收事件描述。

返回值

如果成功返回true,否则返回false。若要获得有关错误的信息,请调用GetLastError()函数。可能错误:

  • 4001 – ERR_INTERNAL_ERROR(一般运行时错误)。
  • 5402 – ERR_CALENDAR_NO_DATA(国家未找到)。
  • 5401 – ERR_CALENDAR_TIMEOUT(超过请求时限)。

例如:

//+------------------------------------------------------------------+

//| 脚本程序起始函数                                                     |

//+------------------------------------------------------------------+

void OnStart()

  {

//--- 德国国家代码(ISO 3166-1 Alpha-2)

   string germany_code="DE";

//--- 获得德国事件

   MqlCalendarEvent events[];

   int events_count=CalendarEventByCountry(germany_code,events);

//--- 在“日志”中显示德国事件

   if(events_count>0)

     {

      PrintFormat("Germany events: %d",events_count);

      ArrayPrint(events);

     }

   else

     {

      PrintFormat("Failed to receive events for the country code %s, error %d",

                  germany_code,GetLastError());

      //--- 脚本提前完成

      return;

     }

//--- 从events[]数组获得最后事件的描述

   MqlCalendarEvent event;

   ulong event_id=events[events_count-1].id;

   if(CalendarEventById(event_id,event))

     {

      MqlCalendarCountry country;

      CalendarCountryById(event.country_id,country);

      PrintFormat("Event description with event_id=%d received",event_id);

      PrintFormat("Country: %s (country code = %d)",country.name,event.country_id);

      PrintFormat("Event name: %s",event.name);

      PrintFormat("Event code: %s",event.event_code);

      PrintFormat("Event importance: %s",EnumToString((ENUM_CALENDAR_EVENT_IMPORTANCE)event.importance));

      PrintFormat("Event type: %s",EnumToString((ENUM_CALENDAR_EVENT_TYPE)event.type));

      PrintFormat("Event sector: %s",EnumToString((ENUM_CALENDAR_EVENT_SECTOR)event.sector));

      PrintFormat("Event frequency: %s",EnumToString((ENUM_CALENDAR_EVENT_FREQUENCY)event.frequency));

      PrintFormat("Event release mode: %s",EnumToString((ENUM_CALENDAR_EVENT_TIMEMODE)event.time_mode));

      PrintFormat("Event measurement unit: %s",EnumToString((ENUM_CALENDAR_EVENT_UNIT)event.unit));

      PrintFormat("Number of decimal places: %d",event.digits);

      PrintFormat("Event multiplier: %s",EnumToString((ENUM_CALENDAR_EVENT_MULTIPLIER)event.multiplier));

      PrintFormat("Source URL: %s",event.source_url);

     }

   else

      PrintFormat("Failed to get event description for event_d=%s, error %d",

                  event_id,GetLastError());

  }

/*

  结果:

  德国事件: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

  接收event_id=276500003事件描述

  国家:德国(国家代码= 276)

  事件名称:Markit综合PMI

  事件代码:markit-composite-pmi

   事件重要性: CALENDAR_IMPORTANCE_MODERATE

   事件类型:CALENDAR_TYPE_INDICATOR

   事件版块:CALENDAR_SECTOR_BUSINESS

   事件频率:CALENDAR_FREQUENCY_MONTH

   事件发布模式: CALENDAR_TIMEMODE_DATETIME

   事件计量单位:CALENDAR_UNIT_NONE

  小数位数:1

   乘数值:CALENDAR_MULTIPLIER_NONE

   源URL:https://www.markiteconomics.com

*/

另见

CalendarEventByCountryCalendarEventByCurrencyCalendarValueById