Indeed, the standard Calendar functions are hard to understand. It's great that the author has figured it out and provided the article with examples.
However, the simplicity of the proposed high-level calendar API does not seem obvious. It is difficult.
Probably, we should designate a list of some most demanded scenarios of Calendar application. And try to implement them.
Indeed, the standard Calendar functions are hard to understand. It's great that the author has figured it out and provided examples.
However, the simplicity of the proposed high-level calendar API does not seem obvious. It is difficult.
Probably, we should designate a list of some most demanded scenarios of Calendar application. And try to implement them.
I would like to have a way to provide a hundred per cent guarantee of synchronisation of news with quotes at any moment of time.
Indeed, the standard Calendar functions are hard to understand. It's great that the author has figured it out and provided examples.
However, the simplicity of the proposed high-level calendar API does not seem obvious. It is difficult.
Probably, we should designate a list of some most demanded scenarios of Calendar application. And try to implement them.
Thanks for your opinion :-)
In my opinion, some difficulty of perception is due to the fact that CiCalendarInfo class deals with three entities: countries, events and values. If we compare it for example with SB trade classes CAccountInfo, CSymbolInfo, etc., there is 1 object in each class - account, symbol, etc. Maybe it would be worth to make a hierarchy of classes, for example, the following: base class - CiCalendarBaseInfo, descendants - CiCalendarCountryInfo, CiCalendarEventInfo and CiCalendarValueInfo. But the last three have their analogues in the form of structures. That's why I gave up the idea.
Probably, we need to define a list of some of the most popular scenarios of using the Calendar. And try to implement them.
There can be as many of them as there are ideas in terms of using the calendar data. You can make a simple informer about the release of events, a calendar panel, an Expert Advisor that trades or takes into account the time of news release, and so on. You can take data from macroeconomic indicators and study their impact on rates by using neural networks. Big data in a word...
The convenience is that you don't need to go to another source. Everything can be done in the MQL5 environment.
Here is what is not clear on the calendar - queries by change_id. Where to get it?
Dmitry, here is for example a standard function.
int CalendarValueLast( ulong& change_id, // change identifier MqlCalendarValue& values[], // array for obtaining value descriptions const string country_code=NULL, // country code name according to ISO 3166-1 alpha-2 const string currency=NULL // country currency code name );
It shows that change_id is a parameter by reference. That is, the server returns it to us. This is a server constant. When the value changes, it means that the state of the calendar database has changed. There is an example EA in the documentation.
Yes, we can also send the last known value of change_id. If the state of the database changes, the CalendarValueLast() function will return the number of new events and overwrite our sent change_id with the new one .
- www.mql5.com
Dimitri, here's an example of a standard function.
In it you can see that change_id is a parameter by reference. That is, the server returns it to us. This is a server constant. When the value changes, it means that the state of the calendar database has changed. There is an example of an EA in the documentation.
That makes sense. Thank you.
Found it in the help:
CalendarValueLast.If change_id = 0 is passed to the function, the function always returns zero, but the current state of the Calendar base is returned in change_id.
Found it in the help:
CalendarValueLast
If change_id = 0 is passed to the function, the function always returns zero, but the current state of the Calendar base is returned in change_id.
Yes, there is such a thing.
I have such lines in the indicator example when prev_calculated == 0:
//--- just to get a change id MqlCalendarValue values[]; gPtrValuesInfo.ValueLastSelectByEvent(gChangeId, values);
And here gChangeId=0. It is zeroed in the initialisation block. Although it is probably more correct to reset gChangeId whenever prev_calculated == 0. And make this variable local.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article MQL5 Cookbook – Economic Calendar has been published:
The article highlights the programming features of the Economic Calendar and considers creating a class for a simplified access to the calendar properties and receiving event values. Developing an indicator using CFTC non-commercial net positions serves as a practical example.
Let's handle the time series structure in the following example. The Test_TS.mq5 script receives data on US non-farm payrolls from January 1, 2016 to November 1, 2021 and displays them on a scientific chart. Let's make it so that the chart has two curves - actual and forecast values. We will use the event reporting period as a timeline.
After launching the script, we first get displaying timeseries values to the journal and second, drawing the diagram on the chart (Fig. 2).
Fig. 2. US Non-Farm Payrolls (2016-2021)
Author: Denis Kirichenko