FxBotLab Buy on MQL5

Guides

How a news filter works in a MetaTrader 5 Expert Advisor

Around big releases such as US jobs numbers or a central bank decision, spreads widen and prices can jump past a stop. A news filter keeps a robot out of the market for those minutes.

Where the news times come from

MetaTrader 5 has an economic calendar built in. It is maintained by MetaQuotes and every MT5 terminal receives it, whatever the broker. An Expert Advisor can read it with the calendar functions of MQL5: it asks for the events of the coming days, and each event comes with a time in trade-server time, a country, a currency and an importance level (low, moderate or high).

No website scraping and no outside feed are needed, which matters on the MQL5 Market: products there may not depend on downloads from third-party servers.

What FxBotLab does with it

Why the filter is off in the Strategy Tester

The calendar functions return no history in the Strategy Tester, so a backtest cannot know when the news was. FxBotLab switches the filter off there and says so on the panel. In practice this means a backtest includes trades that the live robot would have skipped. Keep that in mind when you compare a backtest with a demo account.

Settings worth changing

On 15-minute and 1-hour charts the defaults (30 minutes either side, high impact only) are a reasonable start. On daily charts a news window of an hour hardly matters, because the decision is made once a day on the closed bar. If you trade gold, keep the filter on: US data moves it as much as it moves the dollar pairs.