//+------------------------------------------------------------------+
//| 脚本程序起始函数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 欧盟国家代码(ISO 3166-1 Alpha-2)
string EU_code="EU";
//--- 获得欧盟事件
MqlCalendarEvent events[];
int events_count=CalendarEventByCountry(EU_code,events);
//--- 在“日志”中显示欧盟事件
if(events_count>0)
{
PrintFormat("EU events: %d",events_count);
//--- 减少事件列表,10个事件足以分析
ArrayResize(events,10);
ArrayPrint(events);
}
//--- 查阅“ECB利率决策”事件event_id=999010007
ulong event_id=events[6].id; // 事件ID可在“日历”中更改,因此一定进行验证
string event_name=events[6].name; // “日历”事件的名称
PrintFormat("Get values for event_name=%s event_id=%d",event_name,event_id);
//--- 获得“ECB利率决策”事件的所有值
MqlCalendarValue values[];
//--- 设置事件发生间隔的边界
datetime date_from=0; // 获取可用历史开始的所有事件
datetime date_to=D'01.01.2016'; // 获取2016年以后的事件
if(CalendarValueHistoryByEvent(event_id,values,date_from,date_to))
{
PrintFormat("Received values for %s: %d",
event_name,ArraySize(values));
//--- 减少值列表,10个事件足以分析
ArrayResize(values,10);
ArrayPrint(values);
}
else
{
PrintFormat("Error! Failed to get values for event_id=%d",event_id);
PrintFormat("Error code: %d",GetLastError());
}
}
//---
/*
结果:
欧盟事件:56
[id] [type] [sector] [frequency] [time_mode] [country_id] [unit] [importance] [multiplier] [digits] [source_url] [event_code] [name] [reserv
[0] 999010001 0 5 0 0 999 0 2 0 0 "https://www.ecb.europa.eu/home/html/index.en.html" "ecb-non-monetary-policy-meeting" "ECB Non-monetary Policy Meeting"
[1] 999010002 0 5 0 0 999 0 2 0 0 "https://www.ecb.europa.eu/home/html/index.en.html" "ecb-monetary-policy-meeting-accounts" "ECB Monetary Policy Meeting Accounts"
[2] 999010003 0 5 0 0 999 0 3 0 0 "https://www.ecb.europa.eu/home/html/index.en.html" "ecb-monetary-policy-press-conference" "ECB Monetary Policy Press Conference"
[3] 999010004 0 5 0 0 999 0 3 0 0 "https://www.ecb.europa.eu/home/html/index.en.html" "ecb-president-draghi-speech" "ECB President Draghi Speech"
[4] 999010005 0 5 0 0 999 0 2 0 0 "https://www.ecb.europa.eu/home/html/index.en.html" "ecb-vice-president-vitor-constancio-speech" "ECB Vice President Constancio Speech"
[5] 999010006 1 5 0 0 999 1 3 0 2 "https://www.ecb.europa.eu/home/html/index.en.html" "ecb-deposit-rate-decision" "ECB Deposit Facility Rate Decision"
[6] 999010007 1 5 0 0 999 1 3 0 2 "https://www.ecb.europa.eu/home/html/index.en.html" "ecb-interest-rate-decision" "ECB Interest Rate Decision"
[7] 999010008 0 5 0 0 999 0 2 0 0 "https://www.ecb.europa.eu/home/html/index.en.html" "ecb-economic-bulletin" "ECB Economic Bulletin"
[8] 999010009 1 5 0 0 999 2 2 3 3 "https://www.ecb.europa.eu/home/html/index.en.html" "targeted-ltro" "ECB Targeted LTRO"
[9] 999010010 0 5 0 0 999 0 2 0 0 "https://www.ecb.europa.eu/home/html/index.en.html" "ecb-executive-board-member-praet-speech" "ECB Executive Board Member Praet Speech"
获得event_name=ECB Interest Rate Decision值 event_id=999010007
已接收的“ECB利率决策”事件值:102
[id] [event_id] [time] [period] [revision] [actual_value] [prev_value] [revised_prev_value] [forecast_value] [impact_type] [reserved]
[0] 2776 999010007 2007.03.08 11:45:00 1970.01.01 00:00:00 0 3750000 4250000 -9223372036854775808 -9223372036854775808 0 0
[1] 2777 999010007 2007.05.10 11:45:00 1970.01.01 00:00:00 0 3750000 3750000 -9223372036854775808 -9223372036854775808 0 0
[2] 2778 999010007 2007.06.06 11:45:00 1970.01.01 00:00:00 0 4000000 3750000 -9223372036854775808 -9223372036854775808 0 0
[3] 2779 999010007 2007.07.05 11:45:00 1970.01.01 00:00:00 0 4000000 4000000 -9223372036854775808 -9223372036854775808 0 0
[4] 2780 999010007 2007.08.02 11:45:00 1970.01.01 00:00:00 0 4000000 4000000 -9223372036854775808 -9223372036854775808 0 0
[5] 2781 999010007 2007.09.06 11:45:00 1970.01.01 00:00:00 0 4000000 4000000 -9223372036854775808 -9223372036854775808 0 0
[6] 2782 999010007 2007.10.04 11:45:00 1970.01.01 00:00:00 0 4000000 4000000 -9223372036854775808 -9223372036854775808 0 0
[7] 2783 999010007 2007.11.08 12:45:00 1970.01.01 00:00:00 0 4000000 4000000 -9223372036854775808 -9223372036854775808 0 0
[8] 2784 999010007 2007.12.06 12:45:00 1970.01.01 00:00:00 0 4000000 4000000 -9223372036854775808 -9223372036854775808 0 0
[9] 2785 999010007 2008.01.10 12:45:00 1970.01.01 00:00:00 0 4000000 4000000 -9223372036854775808 -9223372036854775808 0 0
*/
|