This is the traders/coders forum.
MetaQuotes is on the service desk.
Besides, you are having the thread related to
delay:
MQL5: Economic calendar events (data) delayed!
-------------
As to my opinion.
I traded the news events manually and by EA in demo/real accounts for the many years (and you may find some my statements here on this forum).
And
I know that delay with real/actual figures is nothing to be important.
Because there is not a delay in the price movement, and there is no any delay in the time of the news events.
It
may be delay with actual figures published (in the time with maximum spread on real accounts) because of internet or something.
So, your words about "their customers will just have lost much time (and money)" is not a true.
It may be
important for you personally but I think - it is not important for the majority of the traders.
If you really care about some delay for you so write to the service desk it.
This is the traders/coders forum.
MetaQuotes is on the service desk.
Besides, you are having the thread related to
delay:
MQL5: Economic calendar events (data) delayed!
-------------
As to my opinion.
I traded the news events manually and by EA in demo/real accounts for the many years (and you may find some my statements here on this
forum).
And I know that delay with real/actual figures is nothing to be important.
Because there is not a delay in the price
movement, and there is no any delay in the time of the news events.
It may be delay with actual figures published (in the time with maximum spread on real accounts) because of internet or something.
So,
your words about "their customers will just have lost much time (and money)" is not a true.
It may be important for you personally but I think - it is not important for the majority of the traders.
If you really care about some delay for you so write to the service desk it.
I would very much like to write to MetaQuotes' service desk, but they closed it down and refer any customer requests to exactly this forum. If there still is (very well hidden) a service desk please tell me the link and I'll write to them. Otherwise I have no other option than to kindly ask you to bring this issue (and it is one!) to their awareness so that they can fix it!
Since this is the coders forum I would still like to make a feature request for the MQL5 calendar functions: please add a functionality to not just get already published economic events (with delay as discussed), but also to upcoming ones so that our EAs can at least get the planned release time of an event and then make a trade based on price reaction (as you suggested) instead of waiting for delayed economic data (and then probably make a loss), ok? Otherwise we would have to trade manually again or hard-code the datimes of upcoming calendar events, thus taking the new MQL5 calendar functions ad absurdum...
Access to economic calendar data from MQL5 programs - read first post of this thread about HowTo
----------------
-
MQL5: Implemented access to economic calendar data from MQL5
programs.
New functions
CalendarCountryById — gets country description by identifier.
bool CalendarCountryById( const long country_id, // country ID MqlCalendarCountry& country // country description );CalendarEventById — gets event description by identifier.
bool CalendarEventById( const long event_id, // event ID MqlCalendarEvent& event // event description );CalendarValueById — gets event value description by identifier.
bool CalendarValueById( const long value_id, // value ID MqlCalendarValue& value // value description );CalendarEventByCountry — gets the array of available events for the country.
bool CalendarEventByCountry( string country_code, // country code MqlCalendarEvent& events[] // array of events );CalendarEventByCurrency — gets the array of available events for the affected currency.
bool CalendarEventByCurrency( string currency, // currency MqlCalendarEvent& events[] // array of events );CalendarValueHistoryByEvent — gets the array of values for the specified time period, by event identifier.
bool CalendarValueHistoryByEvent( ulong event_id, // event ID MqlCalendarValue& values[], // array of values datetime datetime_from, // period beginning date datetime datetime_to=0 // period end date );CalendarValueHistory — gets the array of values for the specified time period for all events, filtered by country and/or currency.
bool CalendarValueHistory( MqlCalendarValue& values[], // array of values datetime datetime_from, // beginning of period datetime datetime_to=0, // end of period string country_code=NULL, // country code string currency=NULL // currency );CalendarValueLastByEvent — gets an array of last event values by identifier. This function enables the request of the values which have appeared since the previous request. The in/out parameter "change_id" is additionally used for this operation.
Every time the calendar database changes, the "change_id" property (the last change identifier) is updated. During data request, you specify "change_id" and the terminal returns events which appeared after that time, as well as the current "change_id" value, which can be used for the next request. During the first function call, specify the zero "change_id": the function will not return any events, but will return the current "change_id" for further requests.
bool CalendarValueHistory( ulong event_id, // event ID ulong& change_id, // last calendar change ID MqlCalendarValue& values[] // array of values );CalendarValueLast — gets the array of last values for all events, filtered by country and/or currency. This function enables the request of the values which have appeared since the previous request. Similarly to CalendarValueLastByEvent, the "change_id" property is used for the request.
bool CalendarValueHistory( ulong event_id, // event ID ulong& change_id, // last calendar change ID MqlCalendarValue& values[], // array of values string country_code=NULL, // country code string currency=NULL // currency );
New structures
MqlCalendarCountry — country description.
struct MqlCalendarCountry { ulong id; // country ID in ISO 3166-1 string name; // text name of the country string code; // code name of the country in ISO 3166-1 alpha-2 string currency; // country currency code string currency_symbol; // country currency symbol/sign string url_name; // country name used in URL on mql5.com };MqlCalendarEvent — event description.
struct MqlCalendarEvent { ulong id; // event ID ENUM_CALENDAR_EVENT_TYPE type; // event type ENUM_CALENDAR_EVENT_SECTOR sector; // sector to which the event belongs ENUM_CALENDAR_EVENT_FREQUENCY frequency; // event release frequency ENUM_CALENDAR_EVENT_TIMEMODE time_mode; // event release time mode ulong country_id; // country ID ENUM_CALENDAR_EVENT_UNIT unit; // unit for the event values ENUM_CALENDAR_EVENT_IMPORTANCE importance; // event importance ENUM_CALENDAR_EVENT_MULTIPLIER multiplier; // event importance multiplier uint digits; // number of decimal places in the event value string source_url; // source URL string event_code; // event code string name; // text name of the event in the terminal language };MqlCalendarValue — event value description.
struct MqlCalendarValue { ulong id; // value ID ulong event_id; // event ID datetime time; // event date and time datetime period; // period, for which the event is published int revision; // published indicator revision in relation to the reported period long actual_value; // current event value long prev_value; // previous event value long revised_prev_value; // revised previous event value long forecast_value; // forecast event value ENUM_CALENDAR_EVENT_IMPACRT impact_type; // potential impact on the currency rate };
New enumerations
enum ENUM_CALENDAR_EVENT_FREQUENCY { CALENDAR_FREQUENCY_NONE =0, // not used CALENDAR_FREQUENCY_WEEK =1, // weekly CALENDAR_FREQUENCY_MONTH =2, // monthly CALENDAR_FREQUENCY_QUARTER =3, // quarterly CALENDAR_FREQUENCY_YEAR =4, // yearly CALENDAR_FREQUENCY_DAY =5, // daily }; enum ENUM_CALENDAR_EVENT_TYPE { CALENDAR_TYPE_EVENT =0, // event (meeting, speech, etc.) CALENDAR_TYPE_INDICATOR =1, // indicator CALENDAR_TYPE_HOLIDAY =2, // holiday }; enum ENUM_CALENDAR_EVENT_SECTOR { CALENDAR_SECTOR_NONE =0, // no CALENDAR_SECTOR_MARKET =1, // market CALENDAR_SECTOR_GDP =2, // GDP CALENDAR_SECTOR_JOBS =3, // jobs CALENDAR_SECTOR_PRICES =4, // prices CALENDAR_SECTOR_MONEY =5, // money CALENDAR_SECTOR_TRADE =6, // trade CALENDAR_SECTOR_GOVERNMENT =7, // government CALENDAR_SECTOR_BUSINESS =8, // business CALENDAR_SECTOR_CONSUMER =9, // consumer CALENDAR_SECTOR_HOUSING =10, // housing CALENDAR_SECTOR_TAXES =11, // taxes CALENDAR_SECTOR_HOLIDAYS =12, // holidays }; enum ENUM_CALENDAR_EVENT_IMPORTANCE { CALENDAR_IMPORTANCE_LOW =0, // no CALENDAR_IMPORTANCE_NONE =1, // low CALENDAR_IMPORTANCE_MODERATE =2, // moderate CALENDAR_IMPORTANCE_HIGH =3, // high }; enum ENUM_CALENDAR_EVENT_UNIT { CALENDAR_UNIT_NONE =0, // no CALENDAR_UNIT_PERCENT =1, // percent CALENDAR_UNIT_CURRENCY =2, // national currency CALENDAR_UNIT_HOUR =3, // number of hours CALENDAR_UNIT_JOB =4, // number of jobs CALENDAR_UNIT_RIG =5, // number of rigs CALENDAR_UNIT_USD =6, // US dollar CALENDAR_UNIT_PEOPLE =7, // number of people CALENDAR_UNIT_MORTGAGE =8, // number of mortgages CALENDAR_UNIT_VOTE =9, // number of votes CALENDAR_UNIT_BARREL =10, // number of barrels CALENDAR_UNIT_CUBICFEET =11, // volume in cubic feet CALENDAR_UNIT_POSITION =12, // number of job positions CALENDAR_UNIT_BUILDING =13 // number of buildings }; enum ENUM_CALENDAR_EVENT_MULTIPLIER { CALENDAR_MULTIPLIER_NONE =0, // no CALENDAR_MULTIPLIER_THOUSANDS =1, // thousands CALENDAR_MULTIPLIER_MILLIONS =2, // millions CALENDAR_MULTIPLIER_BILLIONS =3, // billions CALENDAR_MULTIPLIER_TRILLIONS =4, // trillions }; enum ENUM_CALENDAR_EVENT_IMPACRT { CALENDAR_IMPACT_NA =0, // not available CALENDAR_IMPACT_POSITIVE =1, // positive CALENDAR_IMPACT_NEGATIVE =2, // negative }; enum ENUM_CALENDAR_EVENT_TIMEMODE { CALENDAR_TIMEMODE_DATETIME =0, // the source publishes the exact time CALENDAR_TIMEMODE_DATE =1, // the event takes the whole day CALENDAR_TIMEMODE_NOTIME =2, // the source does not publish the event time CALENDAR_TIMEMODE_TENTATIVE =3, // the source provides only date, but does not publish the exact time in advance, exact time is added when event occurs };
New error codes
ERR_CALENDAR_MORE_DATA =5400, // the array is small for the whole result (values which fit in the array were passed) ERR_CALENDAR_TIMEOUT =5401, // timed out waiting for a response to the calendar data request ERR_CALENDAR_NO_DATA =5402, // data not found
Forum on trading, automated trading systems and testing trading strategies
All about Calendar tab and Macro Economic Events.
Sergey Golubev, 2019.03.15 16:27
MQL5 Reference - Economic Calendar - CalendarValueLastByEvent
Example of Economic calendar events listenter -
Forum on trading, automated trading systems and testing trading strategies
New MQL5 Economic Calendar function
Rashid Umarov, 2019.03.20 17:10
May it is not that bug that coonects with your code. Run this sample of Economic calendar events listenter. Sorry for Russian comments - didn't have time for translation
//+------------------------------------------------------------------+ //| Demo_CalendarValueLast.mq5 | //| Copyright 2018, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2018, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property description "Пример использования функции CalendarValueLast" #property description " для отлавливания выхода отчета по событию Nonfarm Payrolls." #property description "Для этого необходимо получить текущий идентификатор изменения" #property description " базы Календаря. И затем по этому идентификатору получать" #property description " только новые события для через опрос в таймере" //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- create timer EventSetTimer(60); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- destroy timer EventKillTimer(); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- } //+------------------------------------------------------------------+ //| Timer function | //+------------------------------------------------------------------+ void OnTimer() { //--- идентификатор изменения базы Календаря static ulong calendar_change_id=0; //--- признак первого запуска static bool first=true; //--- массив значений событий MqlCalendarValue values[]; //--- проведем инициализацию - получим текущий calendar_change_id if(first) { //--- получим идентификатор изменения базы Календаря if(CalendarValueLast(calendar_change_id,values)>0) { //--- этот блок кода не может выполниться при первом запуске, но мы его все равно пропишем PrintFormat("%s: Получен текущий идентификатор базы Календаря: change_id=%d", __FUNCTION__,calendar_change_id); //--- выставим флаг и выйдем до следущего события таймера first=false; return; } else { //--- данные не получены (для первого запуска это нормально), проверим наличие ошибки int error_code=GetLastError(); if(error_code==0) { PrintFormat("%s: Получен текущий идентификатор базы Календаря: change_id=%d", __FUNCTION__,calendar_change_id); //--- выставим флаг и выйдем до следущего события таймера first=false; //--- теперь у нас есть значение calendar_change_id return; } else { //--- а вот это действительно ошибка PrintFormat("%s: Не удалось получить события в CalendarValueLast. Код ошибки: %d", __FUNCTION__,error_code); //--- неудачное завершение работы, попробуем заново при следующем вызове таймера return; } } } //--- у нас есть последнее известное значение идентификатора изменения Календаря (change_id) ulong old_change_id=calendar_change_id; //--- проверим - не появилось ли новое значение события "Nonfarm Payrolls" if(CalendarValueLast(calendar_change_id,values)>0) { PrintFormat("%s: Получены новые события для Календаря: %d", __FUNCTION__,ArraySize(values)); //--- выведем в Журнал информацию из массива values ArrayPrint(values); //--- выведем в Журнал значения предыдущего и нового идентификатора Календаря PrintFormat("%s: Предыдущий change_id=%d, новый change_id=%d", __FUNCTION__,old_change_id,calendar_change_id); //--- выведем в Журнал новые события ArrayPrint(values); /* пропишите здесь свой код, который будет обрабатывать появление событий */ } //--- } /* Пример работы слушателя: OnTimer: Получен текущий идентификатор базы Календаря: change_id=33281792 OnTimer: Получены новые события для Календаря: 1 [id] [event_id] [time] [period] [revision] [actual_value] [prev_value] [revised_prev_value] [forecast_value] [impact_type] [reserved] [0] 91040 76020013 2019.03.20 15:30:00 1970.01.01 00:00:00 0 -5077000 -1913000 -9223372036854775808 -4077000 2 0 OnTimer: Предыдущий change_id=33281792, новый change_id=33282048 [id] [event_id] [time] [period] [revision] [actual_value] [prev_value] [revised_prev_value] [forecast_value] [impact_type] [reserved] [0] 91040 76020013 2019.03.20 15:30:00 1970.01.01 00:00:00 0 -5077000 -1913000 -9223372036854775808 -4077000 2 0 OnTimer: Получены новые события для Календаря: 1 [id] [event_id] [time] [period] [revision] [actual_value] [prev_value] [revised_prev_value] [forecast_value] [impact_type] [reserved] [0] 91041 76020013 2019.03.27 15:30:00 1970.01.01 00:00:00 0 -9223372036854775808 -5077000 -9223372036854775808 -7292000 0 0 OnTimer: Предыдущий change_id=33282048, новый change_id=33282560 [id] [event_id] [time] [period] [revision] [actual_value] [prev_value] [revised_prev_value] [forecast_value] [impact_type] [reserved] [0] 91041 76020013 2019.03.27 15:30:00 1970.01.01 00:00:00 0 -9223372036854775808 -5077000 -9223372036854775808 -7292000 0 0 */ //+------------------------------------------------------------------+
I would very much like to write to MetaQuotes' service desk, but they closed it down and refer any customer requests to exactly this forum. If there still is (very well hidden) a service desk please tell me the link and I'll write to them. Otherwise I have no other option than to kindly ask you to bring this issue (and it is one!) to their awareness so that they can fix it!
Since this is the coders forum I would still like to make a feature request for the MQL5 calendar functions: please add a functionality to not just get already published economic events (with delay as discussed), but also to upcoming ones so that our EAs can at least get the planned release time of an event and then make a trade based on price reaction (as you suggested) instead of waiting for delayed economic data (and then probably make a loss), ok? Otherwise we would have to trade manually again or hard-code the datimes of upcoming calendar events, thus taking the new MQL5 calendar functions ad absurdum...
regarding your question towards UPCOMING events: you can use CalendarValueHistory for that purpose, too. Although the function's name suggests that only historical events are dealt with, in fact this isn't true: if you set datetime_to=0 you also get future events. I couldn't get it to work in the strategy tester, but it does work under realtime conditions.
regarding your question towards UPCOMING events: you can use CalendarValueHistory for that purpose, too. Although the function's name suggests that only historical events are dealt with, in fact this isn't true: if you set datetime_to=0 you also get future events. I couldn't get it to work in the strategy tester, but it does work under realtime conditions.
Thank you, Chris70, this should solve half the problem :)
I use the CalendarValueHistory too , but sometimes there is still a delay. today CPI data was coming from USD. it took a minute for the HasActual was true and my EA get the actual data.
Did you allready figur out how to get rid off the delay ?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dear MetaQuotes,
we customers have been waiting for a long time for your MQL5 economic calendar functions and finally they are there (thanks for that!), but the delay at which data are published is often ridiculously huge!
For example take the last US Nonfarm Payrolls (as of 5th July 2019) — they were delayed by 2 minutes and 43 seconds — had we traded this signal we would have completely missed the initial market reaction and sold right into the counter-reaction (and potentially lost much money):
And we've obeserved delays much longer than that, partially over 5 minutes while other calendars (e.g. https://de.investing.com/economic-calendar/) were on time!
This way the new MQL5 economic calendar functions are not just useless, but outright dangerous!
Please make it your top priority to fix this issue, or MetaQuotes and their customers will just have lost much time (and money) with the new MQL5 calendar functions. Please speed up your economic calendar!
Many thanks in advance!