840020006 2023.01.10 17:00 USD 1 Wholesale Inventories m/m (wholesale-inventories), United States (US) | 1.0% | 1.0% | 1.0% | Q4 2023.01.26 15:30 USD 1 Wholesale Inventories m/m (wholesale-inventories), United States (US) | 0.1% | 1.0% | 1.0% | 0.9% Q4 2023.02.08 17:00 USD 1 Wholesale Inventories m/m (wholesale-inventories), United States (US) | 0.1% | 0.1% | 0.1% | Q4 2023.02.28 15:30 USD 1 Wholesale Inventories m/m (wholesale-inventories), United States (US) | | 0.5% | 0.1% | Q1 840080001 2023.01.26 15:30 USD 1 Chicago Fed National Activity Index (chicago-fed-national-activity-index), United States (US) | -0.49 | 0.04 | -0.51 | Dec 2023.01.26 15:30 USD 1 Chicago Fed National Activity Index (chicago-fed-national-activity-index), United States (US) | -0.51 | -0.01 | -0.05 | 0 Nov 2023.02.23 15:30 USD 1 Chicago Fed National Activity Index (chicago-fed-national-activity-index), United States (US) | | 0.03 | -0.49 | Jan
#property script_show_inputs #include <fxsaber\Calendar\Calendar.mqh> // https://www.mql5.com/ru/code/32430 input ulong inEventID = 840020006; input datetime inFrom = D'2023.01.01'; input datetime inTo = D'2023.04.01'; void OnStart() { CALENDAR Calendar; Calendar.Set(inEventID); Calendar.FilterByTime(inFrom, inTo); Print(inEventID); Print(Calendar.ToString()); }
Hello everyone at the MQL5 Community, I have an issue. I am trying to build a News EA that trades the news. I have called the events by country id and the resulting events array contains id, event id, time amongst others. I am mostly interested in the news release time but it is always displaying array[0] if the time has past, I want it to filter and display upcoming event based on current time. I have tried a few approaches but I have not been successful.Your input will be highly appreciated. I have attached my code and also attached a screenshot of the journal outputs.
//US Code string us_code="US"; //--- get all US event values MqlCalendarValue values[]; //--- set the boundaries of the interval we take the events from datetime date_from=StringToTime(today);// take all events from today datetime date_to=0; // 0 means all known events, including the ones that have not occurred yet //--- request US event history since today if(!CalendarValueHistory(values, date_from, date_to, us_code)) { PrintFormat("Error! Failed to get events for country_code=%s", us_code); PrintFormat("Error code: %d", GetLastError()); return; } else PrintFormat("Received event values for country_code=%s: %d", us_code, ArraySize(values)); //--- reduce the size of the array for output to the Journal if(ArraySize(values)>5) ArrayResize(values, 5); //--- output event values to the Journal as they are, without checking or converting to actual values Print("Output calendar values as they are"); ArrayPrint(values); int total=ArraySize(values); //ArrayGetAsSeries(values); ArrayResize(values, total); //--- copy the values with checks and adjustments for(int i=0; i<total; i++) { values[i].id=values[i].id; values[i].event_id=values[i].event_id; values[i].time=values[i].time; } Print("The third method to get calendar values - without checks"); ArrayPrint(values); //Get upcoming event id int event_id = values[0].event_id; //Get upcoming event time datetime comingTime = values[0].time;
Files:
Journal.png
27 kb
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi everyone,
I am currently coding an EA around news trading.
My aim is to trade around given news such as the US GDP values annoucement for example.
To do so, I check the calendar and compare the event IDs of the day with the ones I stored in an array.
However, my problem is not on the code itself but on the event IDs.
I collected the event IDs of the events I wanted to trade but it looks like they are changing over time.
In Janurary, I had an event ID of 840020006 for the US GDP news and in Frebruary the event ID was 840080001.
I am confused because I tought I could use the event IDs to have unique identifiers of the economic event.
Is there another way to have a unique identifier of the news ? The aim would be to have one number that identifies every US GDP QoQ events.
Should I use another parameter and is it even possible ?
Thanks for your help and time, I hope I was explicit enough. If not, don't hesitate to react and I will explain in more details.
Have a great day traders.