- CalendarCountryById
- CalendarEventById
- CalendarValueById
- CalendarCountries
- CalendarEventByCountry
- CalendarEventByCurrency
- CalendarValueHistoryByEvent
- CalendarValueHistory
- CalendarValueLastByEvent
- CalendarValueLast
CalendarValueHistory
Get the array of values for all events in a specified time range with the ability to sort by country and/or currency.
int CalendarValueHistory(
|
Parameters
values[]
[out] MqlCalendarValue type array for receiving event values. See the example of handling calendar events.
datetime_from
[in] Initial date of a time range events are selected from by a specified ID, while datetime_from < datetime_to.
datetime_to=0
[in] End date of a time range events are selected from by a specified ID. If the datetime_to is not set (or is 0), all event values beginning from the specified datetime_from date in the Calendar database are returned (including the values of future events).
country_code=NULL
[in] Country code name (ISO 3166-1 alpha-2)
currency=NULL
[in] Country currency code name.
Return Value
If successful, return the number of available values in the 'values' array, otherwise -1. To get information about an error, call the GetLastError() function. Possible errors:
- 4001 – ERR_INTERNAL_ERROR (general runtime error),
- 4004 – ERR_NOT_ENOUGH_MEMORY (not enough memory for executing a request),
- 5401 – ERR_CALENDAR_TIMEOUT (request time limit exceeded),
- 5400 – ERR_CALENDAR_MORE_DATA (array size is insufficient for receiving descriptions of all values, only the ones that managed to fit in were received),
- errors of failed execution of ArrayResize()
Note
All functions for working with the economic calendar use the trade server time (TimeTradeServer). This means that the time in the MqlCalendarValue structure and the time inputs in the CalendarValueHistoryByEvent/CalendarValueHistory functions are set in a trade server timezone, rather than a user's local time.
If the events[] array of fixed length was passed to the function and there was not enough space to save the entire result, the ERR_CALENDAR_MORE_DATA (5400) error is activated.
If the datetime_to is not set (or is 0), all event values beginning from the specified datetime_from date in the Calendar database are returned (including the values of future events).
For the country_code and currency filters, NULL and "" values are equivalent and mean the absence of the filter.
For country_code, the code field of the MqlCalendarCountry structure, for example "US", "RU" or "EU", should be used.
For currency, the currency field of the MqlCalendarCountry structure, for example "USD", "RUB" or "EUR", should be used.
The filters are applied by conjunction, i.e. logical 'AND' is used to select only the values of events both conditions (country and currency) are simultaneously met for.
The MqlCalendarValue structure provides methods for checking and setting values from the actual_value, forecast_value, prev_value and revised_prev_value fields. If no value is specified, the field stores LONG_MIN (-9223372036854775808).
Please note that the values stored in these field are multiplied by one million. It means that when you receive values in MqlCalendarValue using functions CalendarValueById, CalendarValueHistoryByEvent, CalendarValueHistory, CalendarValueLastByEvent and CalendarValueLast, you should check if the field values are equal to LONG_MIN; if a value is specified in a field, then you should divide the value by 1,000,000 in order to get the value. Another method to get the values is to check and to get values using the functions of the MqlCalendarValue structure.
Example:
//+------------------------------------------------------------------+
|
See also
CalendarCountries, CalendarEventByCountry, CalendarValueHistoryByEvent, CalendarEventById, CalendarValueById