News Guard: EA News Filter and Slippage Logger

News Guard: EA News Filter and Slippage Logger
Download ALL MT5 experts (1835)
YouTube Video Thumbnail



Similar MetaTrader Tools

News Guard: EA News Filter and Slippage Logger

Info

The News Guard: EA News Filter and Slippage Logger is a Expert Advisor for MetaTrader 5 that news guard is a compact module designed to address two common challenges faced by expert advisors (eas) in live trading: unexpected news events and unrecorded slippage. It integrates seamlessly with your existing EA without requiring modifications to its core logic.

Usage

This tool is typically used for automated trading on major forex pairs and gold.

Platform

This Expert Advisor works exclusively on MetaTrader 5 (both build 600+ and newer versions).

Setup

Place the downloaded file in MQL5/Experts folder via File ? Open Data Folder in MetaTrader 5.


How to Install and Use News Guard: EA News Filter and Slippage Logger

1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.

2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.

3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.

4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.

Frequently Asked Questions

Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.

Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.

Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.

What this tool does

News Guard is a compact module designed to address two common challenges faced by Expert Advisors (EAs) in live trading: unexpected news events and unrecorded slippage.

Typical Use Case

This Expert Advisor excels in automated trading and technical analysis on MetaTrader 5.

Compatible Platform & Setup

This Expert Advisor works on MetaTrader 5. Place the file in the MQL5/Experts folder and restart the terminal.

Description & Settings

Related: EA Validation Guard: Pre-Trade Request Checker - another powerful expert for MetaTrader 5 traders.

News Guard is a compact module designed to address two common challenges faced by Expert Advisors (EAs) in live trading: unexpected news events and unrecorded slippage. It integrates seamlessly with your existing EA without requiring modifications to its core logic.

Also recommended: Economic News Pausing Utility for Expert Advisors - similar expert with strong performance on MetaTrader 5.


1) News Filter (Class CNewsGuard)

This component monitors news releases that could impact your trading. It reads the economic calendar data built into MT5 (CalendarValueHistory) for the currencies associated with your chart's symbol (e.g., EUR and USD for EURUSD). The module supports currency overrides for metals and indices.

You can configure a quiet period, specifying the number of minutes before and after a news release during which new entries will be blocked. Additionally, you can choose whether to consider only high-impact news releases or both high and medium-impact ones.

Your EA can query the filter using the IsBlocked() function. This function returns a clear explanation of why trading is blocked, if applicable (e.g., "Non-Farm Payrolls (USD) on 2026-01-09 15:30 - within 30 minutes/15 minutes period").

The NextEvent() function provides the date and time of the next scheduled news release, which can be displayed on a panel or logged.

In case the economic calendar data is unavailable (e.g., during offline periods or in the Strategy Tester), the module enters an honest failure mode, reporting CALENDAR_UNAVAILABLE instead of simulating normal operation. Your EA can then decide how to handle this situation, for instance, by using the "fail closed" switch.

2) Slippage Log (Class CSlippageLog)

This component tracks the difference between the requested and executed prices for your trades. When your EA sends an order, you record the requested price using NoteRequest(order ticket, price).

When a trade is executed (detected in OnTradeTransaction via OnDeal()), the slippage is calculated in points. Positive slippage consistently indicates that the execution was worse than requested for both buys and sells.

A CSV line is appended to a log file containing: time, symbol, deal, order, type, volume, request price, executed price, and slippage.

Statistics such as the number of recorded deals, average slippage, worst slippage, and the count of trades where the request price was not recorded are maintained in memory for real-time monitoring.

Limitations

This module does not execute, modify, or close orders, nor does it make entry decisions. Its sole purpose is to provide information and maintain records, ensuring your EA retains full control. The example EA includes placeholder entry signals that always return false, meaning the example EA itself does not execute trades. The panel and code clearly mark the exact integration points.

Setup

Place the NewsGuard.mqh file in the same folder as your EA or in the MQL5\Include folder.

Attach the NewsGuardExampleEA to a chart to observe the functionality of the panel and logs.

To integrate News Guard into your own EA, add #include "NewsGuard.mqh". Create the two necessary objects. Before placing an order, query NewEntryAllowed() (following the pattern shown in the example's OnTick function). After sending each order, call NoteRequest(). Forward trade transactions from OnTradeTransaction to the slippage logger.

Example EA Input Parameters (explained)

Block Period Before/After Release (Quiet Period): Size of the quiet period window.

Which Releases to Count: High-impact releases only, or both high and medium-impact.

Currency Overrides: Used when a symbol's name does not contain the currencies of interest.

Block Entries When Calendar Unavailable: The fail-closed switch.

Update Interval, Slippage Filename, Common File Folder Toggle, Panel On/Off.

This tool is available free of charge and is part of a series of measurement and risk management tools. The author develops display, measurement, and risk management utilities for MT5 and also undertakes custom development through the MQL5 freelance service.

You may also like: Prop Firm Equity Guard: Protect Your Challenge - excellent alternative for expert users on MetaTrader 5.

Source Code

#property copyright "RobotFX"
#property version     "1.00"
#property description "This code is educational. Feel free to use, modify and upgrade as you wish. Visit ROBOTFX.ORG for professional trading tools"
#property strict
#include "NewsGuard.mqh"
input int InpBlockBeforeMinutes = 30;
input int InpBlockAfterMinutes = 15;
input NG_MIN_IMPORTANCE InpMinImportance = NG_IMP_HIGH_ONLY;
input string InpCurrencyOverride1 = "";
input string InpCurrencyOverride2 = "";

.......

Leave your opinion, ask a question, share some knowledge

⚠ Limitations & Risk Warning

  • This tool is provided for educational and testing purposes only.
  • Past performance does not guarantee future results.
  • Trading involves substantial risk of loss. Use on a demo account first.
  • Results may vary depending on market conditions, broker, and settings.
  • We recommend thorough backtesting and forward testing before using with real funds.
© ROBOTFX Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.