Getting CalendarValues go wrong

 

Hi there,

I currently work on getting CalendarEvents and CalendarValues becasue I want to make a bot which avoids huge events such as CES and FOMC.

And checked the page of CalendarValueHistroy and coded below:

    string US_code="US";
    MqlCalendarValue values[];
    datetime date_from=D'2021.06.01';
    datetime date_to=0;
    if(CalendarValueHistory(values, date_from, date_to, US_code)) {
        PrintFormat("Received event values for country_code=%s: %d",
                    US_code, ArraySize(values));
        ArrayResize(values, 5);
        ArrayPrint(values);
    } else {
        PrintFormat("Error!Failed to receive events for country_code=%s", US_code);
        PrintFormat("Error code: %d", GetLastError());
    }


The output with this is:

2021.08.05 01:17:35.832 Core 1  2021.07.01 10:37:54   Received event values for country_code=US: 0
2021.08.05 01:17:35.832 Core 1  2021.07.01 10:37:54        [id]   [event_id]              [time]            [period] [revision] [actual_value] [prev_value] [revised_prev_value] [forecast_value] [impact_type] [reserved]
2021.08.05 01:17:35.832 Core 1  2021.07.01 10:37:54   [ 0]    0 755914244096 1970.01.01 00:00:00 0000.00.00 00:00:00          0              0          208                    0              224             0        ...
2021.08.05 01:17:35.832 Core 1  2021.07.01 10:37:54   [ 1]    0            0 1970.01.01 00:00:00 1970.01.01 00:00:00          0              0            0                    0                0             0        ...
2021.08.05 01:17:35.832 Core 1  2021.07.01 10:37:54   [ 2]    0            0 1970.01.01 00:00:00 1970.01.01 00:00:00          0              0            0                    0                0             0        ...
2021.08.05 01:17:35.832 Core 1  2021.07.01 10:37:54   [ 3]    0            0 1970.01.01 00:00:00 1970.01.01 00:00:00          0              0            0                    0                0             0        ...
2021.08.05 01:17:35.832 Core 1  2021.07.01 10:37:54   [ 4]    0            0 1970.01.01 00:00:00 1970.01.01 00:00:00          0              0            0                    0                0             0        ...

I'm pretty sure US had more events but it shows me only 1 event, and also I see no time or period even [0].

Is there any ways to get right CalendarValue-data on backtests?

Thank you.

Testing trading strategies on real ticks
Testing trading strategies on real ticks
  • www.mql5.com
The article provides the results of testing a simple trading strategy in three modes: "1 minute OHLC", "Every tick" and "Every tick based on real ticks" using actual historical data.