实现从MQL5程序访问经济日历数据。
新函数
CalendarCountryById — 根据标识符获得国家描述。
bool CalendarCountryById(
const long country_id,
MqlCalendarCountry& country
);
CalendarEventById — 根据标识符获得事件描述。
bool CalendarEventById(
const long event_id,
MqlCalendarEvent& event
);
CalendarValueById — 根据标识符获得事件值描述。
bool CalendarValueById(
const long value_id,
MqlCalendarValue& value
);
CalendarEventByCountry — 获得国家可用事件的数组。
bool CalendarEventByCountry(
string country_code,
MqlCalendarEvent& events[]
);
CalendarEventByCurrency — 获得受影响货币的可用事件数组。
bool CalendarEventByCurrency(
string currency,
MqlCalendarEvent& events[]
);
CalendarValueHistoryByEvent — 根据事件标识符,获取特定时期的值数组。
bool CalendarValueHistoryByEvent(
ulong event_id,
MqlCalendarValue& values[],
datetime datetime_from,
datetime datetime_to=0
);
CalendarValueHistory — 根据国家和/或货币筛选,获取所有事件在特定时期的值数组。
bool CalendarValueHistory(
MqlCalendarValue& values[],
datetime datetime_from,
datetime datetime_to=0,
string country_code=NULL,
string currency=NULL
);
CalendarValueLastByEvent — 根据标识符获取最后时间值的数组。此函数可以请求自上一个请求出现的值。这个操作还使用了in/out参数"change_id"。
每当日历数据库出现变化,"change_id"属性(最后更改的标识符)都会更新。数据请求期间,您指定"change_id"则程序端返回在此之后出现的事件,以及可用于下一个请求的"change_id"当前值。在第一个函数调用期间,指定"change_id"为零:该函数将不返回任何事件,但将为进一步请求返回当前"change_id"。
bool CalendarValueHistory(
ulong event_id,
ulong& change_id,
MqlCalendarValue& values[]
);
CalendarValueLast — 根据国家和/或货币筛选,获取所有事件最后值的数组。此函数可以请求自上一个请求出现的值。类似于CalendarValueLastByEvent,请求使用"change_id"属性。
bool CalendarValueHistory(
ulong event_id,
ulong& change_id,
MqlCalendarValue& values[],
string country_code=NULL,
string currency=NULL
);
新结构
MqlCalendarCountry — 国家描述。
struct MqlCalendarCountry
{
ulong id;
string name;
string code;
string currency;
string currency_symbol;
string url_name;
};
MqlCalendarEvent — 事件描述。
struct MqlCalendarEvent
{
ulong id;
ENUM_CALENDAR_EVENT_TYPE type;
ENUM_CALENDAR_EVENT_SECTOR sector;
ENUM_CALENDAR_EVENT_FREQUENCY frequency;
ENUM_CALENDAR_EVENT_TIMEMODE time_mode;
ulong country_id;
ENUM_CALENDAR_EVENT_UNIT unit;
ENUM_CALENDAR_EVENT_IMPORTANCE importance;
ENUM_CALENDAR_EVENT_MULTIPLIER multiplier;
uint digits;
string source_url;
string event_code;
string name;
};
MqlCalendarValue — 事件值描述。
struct MqlCalendarValue
{
ulong id;
ulong event_id;
datetime time;
datetime period;
int revision;
long actual_value;
long prev_value;
long revised_prev_value;
long forecast_value;
ENUM_CALENDAR_EVENT_IMPACRT impact_type;
};
新枚举
enum ENUM_CALENDAR_EVENT_FREQUENCY
{
CALENDAR_FREQUENCY_NONE =0,
CALENDAR_FREQUENCY_WEEK =1,
CALENDAR_FREQUENCY_MONTH =2,
CALENDAR_FREQUENCY_QUARTER =3,
CALENDAR_FREQUENCY_YEAR =4,
CALENDAR_FREQUENCY_DAY =5,
};
enum ENUM_CALENDAR_EVENT_TYPE
{
CALENDAR_TYPE_EVENT =0,
CALENDAR_TYPE_INDICATOR =1,
CALENDAR_TYPE_HOLIDAY =2,
};
enum ENUM_CALENDAR_EVENT_SECTOR
{
CALENDAR_SECTOR_NONE =0,
CALENDAR_SECTOR_MARKET =1,
CALENDAR_SECTOR_GDP =2,
CALENDAR_SECTOR_JOBS =3,
CALENDAR_SECTOR_PRICES =4,
CALENDAR_SECTOR_MONEY =5,
CALENDAR_SECTOR_TRADE =6,
CALENDAR_SECTOR_GOVERNMENT =7,
CALENDAR_SECTOR_BUSINESS =8,
CALENDAR_SECTOR_CONSUMER =9,
CALENDAR_SECTOR_HOUSING =10,
CALENDAR_SECTOR_TAXES =11,
CALENDAR_SECTOR_HOLIDAYS =12,
};
enum ENUM_CALENDAR_EVENT_IMPORTANCE
{
CALENDAR_IMPORTANCE_NONE =0,
CALENDAR_IMPORTANCE_LOW =1,
CALENDAR_IMPORTANCE_MODERATE =2,
CALENDAR_IMPORTANCE_HIGH =3,
};
enum ENUM_CALENDAR_EVENT_UNIT
{
CALENDAR_UNIT_NONE =0,
CALENDAR_UNIT_PERCENT =1,
CALENDAR_UNIT_CURRENCY =2,
CALENDAR_UNIT_HOUR =3,
CALENDAR_UNIT_JOB =4,
CALENDAR_UNIT_RIG =5,
CALENDAR_UNIT_USD =6,
CALENDAR_UNIT_PEOPLE =7,
CALENDAR_UNIT_MORTGAGE =8,
CALENDAR_UNIT_VOTE =9,
CALENDAR_UNIT_BARREL =10,
CALENDAR_UNIT_CUBICFEET =11,
CALENDAR_UNIT_POSITION =12,
CALENDAR_UNIT_BUILDING =13
};
enum ENUM_CALENDAR_EVENT_MULTIPLIER
{
CALENDAR_MULTIPLIER_NONE =0,
CALENDAR_MULTIPLIER_THOUSANDS =1,
CALENDAR_MULTIPLIER_MILLIONS =2,
CALENDAR_MULTIPLIER_BILLIONS =3,
CALENDAR_MULTIPLIER_TRILLIONS =4,
};
enum ENUM_CALENDAR_EVENT_IMPACRT
{
CALENDAR_IMPACT_NA =0,
CALENDAR_IMPACT_POSITIVE =1,
CALENDAR_IMPACT_NEGATIVE =2,
};
enum ENUM_CALENDAR_EVENT_TIMEMODE
{
CALENDAR_TIMEMODE_DATETIME =0,
CALENDAR_TIMEMODE_DATE =1,
CALENDAR_TIMEMODE_NOTIME =2,
CALENDAR_TIMEMODE_TENTATIVE =3,
};
新错误代码
ERR_CALENDAR_MORE_DATA =5400,
ERR_CALENDAR_TIMEOUT =5401,
ERR_CALENDAR_NO_DATA =5402,