Why CalendarEventByCurrency("EUR",events); return ERROR 5401 ?

 

Dear all,

I want to use CalendarEventByCurrency function but it return Error 5041 when call it first time after opening MT5 terminal. It also takes 50seconds before returning error. When I call it second, third, fourth time it works OK.

What can I do to work first time already?

MqlCalendarEvent getEventByTypeImportance( ENUM_CALENDAR_EVENT_TYPE newsType, ENUM_CALENDAR_EVENT_IMPORTANCE newsImportance ) {
   
   MqlCalendarEvent event;
   MqlCalendarEvent events[];
   int count = CalendarEventByCurrency("EUR",events);
   
   if( count > 0 ) {
   
      event = events[0];
   }
   else {
      Alert( "Error getting News data = " + GetLastError());
   }
   
   return event;
}


And this is error that I get first time:

CalendarEventByCurrency
  • 5401 – ERR_CALENDAR_TIMEOUT (request time limit exceeded),


I hope someone know answer or is this is BUG that can be solved with upgrade.


BR, Igor

 
Igor Zizek:

Dear all,

I want to use CalendarEventByCurrency function but it return Error 5041 when call it first time after opening MT5 terminal. It also takes 20seconds before returning error. When I call it second, third, fourth time it works OK.

What can I do to work first time already?


And this is error that I get first time:

CalendarEventByCurrency
  • 5401 – ERR_CALENDAR_TIMEOUT (request time limit exceeded),


I hope someone know answer or is this is BUG that can be solved with upgrade.


BR, Igor

do not call it in OnInit, but use OnTimer. Your terminal first needs to sync the data, so the first call will take longer. Then it is fast. You need to deal with it inside your code.
 

calling CalendarEventByCurrency function onTimer will freeze my chart and EA for one minute. This is not ok for users.

How can I call some function in new thread or in some way with async function call in MetaTrader 5?

I want to call function CalendarEventByCurrency in paralel on start of program once that next time I call it will work instantly.

CalendarEventByCurrency("EUR",events);


Can anyone have experience with threads or async function call in MT5? Or how to handle calling this function without delay of one minute?

 
Igor Zizek #:

calling CalendarEventByCurrency function onTimer will freeze my chart and EA for one minute. This is not ok for users.

How can I call some function in new thread or in some way with async function call in MetaTrader 5?

I want to call function CalendarEventByCurrency in paralel on start of program once that next time I call it will work instantly.


Can anyone have experience with threads or async function call in MT5? Or how to handle calling this function without delay of one minute?

create a service. Let the service do the initial call.
 

This is not acceptable with hundreds of users. I hope mql5 finds some solution for this bug.

 
Igor Zizek #:

This is not acceptable with hundreds of users. I hope mql5 finds some solution for this bug.

In fact this is not a bug. Something else although is, and it is wanted in such a way. - You will notice once you try to read current event values. - They will be massive delays between updates on the calendar web-page and the calender API in MQL. - So its only usable to know when an event takes place, but you cannot know the actual values to that event.

Anyways, there arre lots of other "inacceptables" we have to live with. - And your complaint isnt even really anything to be excited about. - Just solve it properly, and you get what you want.

 
Dominik Christian Egert #:

In fact this is not a bug. Something else although is, and it is wanted in such a way. - You will notice once you try to read current event values. - They will be massive delays between updates on the calendar web-page and the calender API in MQL. - So its only usable to know when an event takes place, but you cannot know the actual values to that event.

Anyways, there arre lots of other "inacceptables" we have to live with. - And your complaint isnt even really anything to be excited about. - Just solve it properly, and you get what you want.

Are you saying that the calendar update is delayed on purpose when used through MQL ?
 
Alain Verleyen #:
Are you saying that the calendar update is delayed on purpose when used through MQL ?
Yes. And it's logical.
 
Dominik Christian Egert #:
Yes. And it's logical.
Really ? why logical ?
 

I solve issue with this function call:

CalendarValueHistory(values,date_from,date_to, NULL, "EUR")


This function works great!

 
Alain Verleyen #:
Really ? why logical ?
Think about following:

How could the content of the calendar be protected from being distributed if delivered by an API? - No legal contract will hold up, and even if, how would you want to enforce it? How would you want to track down which user is not complying to EULA or Use-Policy?

So what measures could be taken to protect the calendar from being copied and redistributed?
Reason: