//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//--- country code for EU (ISO 3166-1 Alpha-2)
string EU_code="EU";
//--- get EU events
MqlCalendarEvent events[];
int events_count=CalendarEventByCountry(EU_code,events);
//--- display EU events in the Journal
if(events_count>0)
{
PrintFormat("EU events: %d",events_count);
//--- reduce the event list, 10 events are sufficient for analysis
ArrayResize(events,10);
ArrayPrint(events);
}
//--- see that the "ECB Interest Rate Decision" event has event_id=999010007
ulong event_id=events[6].id; // the event's ID may change in the Calendar, so be sure to verify
string event_name=events[6].name; // name of a Calendar event
PrintFormat("Get values for event_name=%s event_id=%d",event_name,event_id);
//--- get all values of the "ECB Interest Rate Decision" event
MqlCalendarValue values[];
//--- set the boundaries of the interval we take the events from
datetime date_from=0; // take all events from the beginning of the available history
datetime date_to=D'01.01.2016'; // take events not older than 2016
if(CalendarValueHistoryByEvent(event_id,values,date_from,date_to))
{
PrintFormat("Received values for %s: %d",
event_name,ArraySize(values));
//--- reduce the value list, 10 events are sufficient for analysis
ArrayResize(values,10);
ArrayPrint(values);
}
else
{
PrintFormat("Error! Failed to get values for event_id=%d",event_id);
PrintFormat("Error code: %d",GetLastError());
}
}
//---
/*
Result:
EU events: 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"
Get values for event_name=ECB Interest Rate Decision event_id=999010007
Received ECB Interest Rate Decision event values: 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
*/
|