Code Library / Session/Time
MQL4 News Avoidance
Pause EA during high-impact news events.
Language: MQL4 · Category: Session/Time · Tags: news filter, MQL4, high impact, avoid news, EA safety
Source code
input int MinBefore=30; input int MinAfter=15;
datetime NewsTimes[];
bool IsNewsTime() {
datetime now=TimeCurrent();
for(int i=0;i<ArraySize(NewsTimes);i++)
if(now>=NewsTimes[i]-MinBefore*60&&now<=NewsTimes[i]+MinAfter*60) return true;
return false;
}How to use this snippet
This is a building block, not a finished trading system. Paste it into your own MQL4 project, compile it, and test it on a demo account with your broker's real spreads before relying on it. If MetaEditor reports errors, the compilation error fixer can help.