// MQL5 – news_week.csv in Common\Files (shared by MT4 and MT5 on this PC)
// date_wib;time_wib;unix_utc;currency;impact(H/M/L/X);title;forecast;previous;actual
bool NewsNear(const string cur,const int minBefore,const int minAfter)
{
int h=FileOpen("news_week.csv",FILE_READ|FILE_CSV|FILE_COMMON|FILE_ANSI,';');
if(h==INVALID_HANDLE) return(false);
bool found=false;
while(!FileIsEnding(h))
{
FileReadString(h); FileReadString(h);
datetime t=(datetime)StringToInteger(FileReadString(h));
string c=FileReadString(h), imp=FileReadString(h);
while(!FileIsLineEnding(h) && !FileIsEnding(h)) FileReadString(h);
if(c!=cur || imp!="H") continue;
datetime now=TimeGMT();
if(now>=t-minBefore*60 && now<=t+minAfter*60){found=true;break;}
}
FileClose(h);
return(found);
}
// MT5 also has a built-in economic calendar:
// MqlCalendarValue v[]; CalendarValueHistory(v, TimeCurrent()-86400, TimeCurrent()+7*86400, NULL, "USD");
// news_week.csv (separator ;) in Common\Files
// date_wib;time_wib;unix_utc;currency;impact(H/M/L/X);title;forecast;previous;actual
bool NewsNear(string cur,int minBefore,int minAfter){
int h=FileOpen("news_week.csv",FILE_READ|FILE_CSV|FILE_COMMON|FILE_ANSI,';');
if(h==INVALID_HANDLE) return(false);
bool found=false;
while(!FileIsEnding(h)){
FileReadString(h); FileReadString(h);
datetime t=(datetime)StringToInteger(FileReadString(h));
string c=FileReadString(h),imp=FileReadString(h);
while(!FileIsLineEnding(h) && !FileIsEnding(h)) FileReadString(h);
if(c!=cur || imp!="H") continue;
datetime now=TimeGMT();
if(now>=t-minBefore*60 && now<=t+minAfter*60){found=true;break;}
}
FileClose(h);
return(found);
}