Hello Developers, I am happy to announce that I have done some improvements to this code and now it also displays the events on the chart, for reference...
Here is how the block looks like

Enjoy the latest main code
/*
int minbeforeEvent = 60*24;
int minAfterEvent = 60*24;
string currency_code = "";
string country_code=NULL; //--- country code (ISO 3166-1 Alpha-2)
ENUM_CALENDAR_EVENT_IMPORTANCE min_event_importance = CALENDAR_IMPORTANCE_HIGH;
*/
int FilteredEventsCount = 0;
MqlCalendarValue values[];
//--- set the boundaries of the interval we take the events from
datetime date_from=TimeCurrent() - (60*minbeforeEvent);
datetime date_to=TimeCurrent() + (60*minAfterEvent); // 0 means all known events, including the ones that have not occurred yet
//Print(TimeToString(TimeCurrent(), TIME_DATE|TIME_SECONDS), " -> Searching from ", TimeToString(date_from, TIME_DATE|TIME_SECONDS), " to ", TimeToString(date_to,TIME_DATE|TIME_SECONDS));
//--- request event history since the beginning to future time
//if(verbose) Print("Begin Searching for events from " + TimeToString(date_from,TIME_DATE|TIME_SECONDS) + " to " + TimeToString(date_to,TIME_DATE|TIME_SECONDS) + " For Country " + country_code + ", currency " + currency_code );
if(!CalendarValueHistory(values, date_from, 0, country_code, currency_code))
{
PrintFormat("Error! Failed to get events for country_code=(%s), currency=(%s)", country_code, currency_code);
PrintFormat("Error code: %d", GetLastError());
} else {
//if(verbose) Print("Found some events");
//PrintFormat("Received event values for country_code=(%s), currency=(%s) is (%d)", country_code, currency_code, ArraySize(values));
int total=ArraySize(values);
string commentString = "";
for(int i=0; i<total; i++)
{
//if(values[i].impact_type < )
MqlCalendarEvent event;
ulong event_id=values[i].event_id;
if(CalendarEventById(event_id,event))
{
if(((ENUM_CALENDAR_EVENT_IMPORTANCE)event.importance >= min_event_importance )
&& (values[i].time <= date_to)
)
{
FilteredEventsCount++;
commentString = commentString + TimeToString(values[i].time,TIME_DATE|TIME_SECONDS) + " " + event.name + " " + EnumToString((ENUM_CALENDAR_EVENT_IMPORTANCE)event.importance ) + "\n";
}
}
}
commentString = "MQL5 returned " + FilteredEventsCount + " events from " + TimeToString(date_from,TIME_DATE|TIME_SECONDS) + " to " + TimeToString(date_to,TIME_DATE|TIME_SECONDS) + " For Country " + country_code + ", currency " + currency_code + "\n" + commentString;
if(verbose) Comment(commentString);
}
if( FilteredEventsCount > 0 )
{~next~}
else
{~inext~}










