New MQL5 Economic Calendar function

 

Hello,


has anybody got the new MQL5 calendar functions (see https://www.metatrader5.com/en/releasenotes) to work?

MqlCalendarValue value[];

ulong changeID;

CalendarValueLastByEvent(840040003,changeID,value);

ArrayPrint(value);


...does work but it only returns 0-values for datetime 1970 01 01.


Any solutions?


Thanks!

What's new in MetaTrader 5
What's new in MetaTrader 5
  • www.metatrader5.com
MetaTrader 5 Platform build 2005: Economic Calendar, MQL5 applications as services and R language API Terminal Completely revised built-in Economic Calendar. The Economic Calendar is our proprietary solution. Therein you will find over 600 financial news and indicators related to the 13 largest global economies: USA, European Union, Japan...
 
Documentation on MQL5: Economic Calendar / CalendarValueLastByEvent
Documentation on MQL5: Economic Calendar / CalendarValueLastByEvent
  • www.mql5.com
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), 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...
 

Thank you, Rashid, but even if I update the change_id to the current one and size the value-array to 9999999...

MqlCalendarValue value[9999999];

ulong changeID=33212160;



int OnInit()

  {



   CalendarValueLastByEvent(840040003,changeID,value);

   ArrayPrint(value);

   return(INIT_SUCCEEDED);

  }


...only  0-values for datetime 1970 01 01 are returned:


Can you please adapt my above code so that actual values are returned?


Thank you very much!

 
bromelio:

Thank you, Rashid, but even if I update the change_id to the current one and size the value-array to 9999999...


...only  0-values for datetime 1970 01 01 are returned:


Can you please adapt my above code so that actual values are returned?

It seems that we found out the issue  resposible for such behaviour. Wait for next beta build please.

Sorry for inconvenience

 
Rashid Umarov:

It seems that we found out the issue  resposible for such behaviour. Wait for next beta build please.

Sorry for inconvenience

Ok, thank you for your response and a timely fix in advance!

By the way, MetaQuotes would have had the chance to fix this bug in private because I reported it via the official contact form, but they turned me down because they no longer accept user requests/proposals, which is kind of sad for the users and obviously for MetaQuotes, too. Otherwise it's a great platform and I don't understand why they hide from their (end) customers behind high walls. They should be proud and open to praise as well as to feedback, would make for a first-class reputation and product!

 
bromelio:

Ok, thank you for your response and a timely fix in advance!

By the way, MetaQuotes would have had the chance to fix this bug in private because I reported it via the official contact form, but they turned me down because they no longer accept user requests/proposals, which is kind of sad for the users and obviously for MetaQuotes, too. Otherwise it's a great platform and I don't understand why they hide from their (end) customers behind high walls. They should be proud and open to praise as well as to feedback, would make for a first-class reputation and product!

For information - 

Forum on trading, automatic trading systems and testing of trading strategies

The "Service Desk" section disappeared

MetaQuotes Software Corp. , 2018.08.09 12:56

Technical questions are now only through the forum.

The effect of the scale of user questions on all occasions hinders the work of our company. We turn to full automation MQL5.community 

Forum on trading, automatic trading systems and testing of trading strategies

The "Service Desk" section disappeared

MetaQuotes Software Corp. , 2018.08.09 15:28

Create separate threads with a full description, please. Do not add everything to one topic.

First of all involve other forum participants to analyze the situation.

Try to describe the problem as fully as possible, attach logs, screenshots, sample code, and so on. The main thing is that there was no game of ping-pong, when only a 5-10 step of questions / answers is collected enough material to analyze the situation and play.

Any technical problem should have an answer to the question "can I reproduce". If there is no answer, then the probability of failure of the request is high.


Unfortunately, we can no longer engage in a massive and constantly growing volume of poorly qualified inquiries and frankly educational issues.

Our employees are not teachers in trading or programming.

 
bromelio:

Ok, thank you for your response and a timely fix in advance!

By the way, MetaQuotes would have had the chance to fix this bug in private because I reported it via the official contact form,

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
*/  
//+------------------------------------------------------------------+
 
All funstions are availble with samples - https://www.mql5.com/en/docs/calendar
Documentation on MQL5: Economic Calendar
Documentation on MQL5: Economic Calendar
  • www.mql5.com
This section describes the functions for working with the economic calendar available directly in the MetaTrader platform. The economic calendar is a ready-made encyclopedia featuring descriptions of macroeconomic indicators, their release dates and degrees of importance. Relevant values of macroeconomic indicators are sent to the MetaTrader...
 

Hi Rashid,

many thanks, great work! However, I noticed that many calendar values are delivered with (partially huge) delay, e.g. the last ISM United States Manufacturing Purchasing Managers Index (PMI) as of 1st July 2019 was delivered with nearly 2 minutes (!) delay — please compare the planned and actual times in the below screenshots. Had I traded the signal at that time I would have incurred heavy losses during the following market counter-reaction, so basically the Economic calendar functions are currrently in large part useless or even dangerous unfortunately. What is MetaQuotes doing to speed up their calendar signals, please?





Many thanks in advance!

Reason: