Join our fan page
- Views:
- 44
- Rating:
- Published:
-
Need a robot or indicator based on this code? Order it on Freelance Go to Freelance
CNewsFilter answers one question for your Expert Advisor: is it news time right now? It reads the economic calendar built into MetaTrader 5, keeps the events of the currencies you choose with the importance you choose, and blocks a window of minutes before and after each release. Use it to skip new entries, or to close or protect trades, around high-impact news.

How to use it in an EA
#include <NewsFilter.mqh>
CNewsFilter news;
int OnInit()
{
news.SetCurrenciesFromSymbol(_Symbol); // or news.SetCurrencies("USD,EUR");
news.SetImportance(CALENDAR_IMPORTANCE_HIGH);
news.SetWindow(30, 30); // minutes before / after
return(INIT_SUCCEEDED);
}
void OnTick()
{
if(news.IsNewsTime())
return; // no new entries around the news
//--- your strategy
} Methods
- SetCurrenciesFromSymbol(symbol): the base, profit and margin currency of the symbol. SetCurrencies("USD,EUR"): your own list.
- SetImportance(importance): the minimum importance (low, moderate or high).
- SetWindow(before, after): minutes blocked before and after each release.
- IsNewsTime(): true while the time is inside a window.
- CurrentEvent() and NextEvent(): name, currency and time of the event, for your own panels.
- Total() and Event(i): all loaded events, sorted by time.
- SetRefresh(seconds), SetLookAhead(hours): cache refresh (default 5 minutes) and how far ahead the events are loaded (default 48 hours).
Good to know
- It uses the calendar of the terminal: no web requests, no DLL, nothing to allow in the settings.
- Event times are trade-server times, the same clock as TimeTradeServer().
- Only events with an exact release time are used; holidays and tentative events are skipped.
- The economic calendar is not available in the Strategy Tester. There IsNewsTime() always returns false and a note is printed once.
Demo
NewsFilterDemo.mq5 never trades on an account. In the Strategy Tester the calendar is not available, so there it opens and closes one small test trade a day instead. It shows on the chart whether trading is blocked right now and lists the next events. Inputs: currencies (empty = chart symbol), minimum importance, minutes before and after, number of events to list. Put NewsFilter.mqh into MQL5\Include and the demo into MQL5\Experts.
Compression Breakout Channels with Buy and Sell Volume
Finds volatility compressions as they form, boxes each one as a channel with ATR edge bands and marks the bar that breaks out of it. Inside the live channels: buy and sell volume split from M1 bars, drawn as candles and text, plus a gauge of the current volume delta. Breakout arrows in buffers for EAs.
Multi-TF Data Grabber Lite — Free Clean CSV Export (M1/M15/H1 + Indicators)
Free script exporting clean, deterministic OHLC + tick volume + 4 indicators (MA, RSI, MACD, ATR) for M1/M15/H1 to CSV. Closed bars only, zero lookahead — ideal for analysis and ML datasets.
Magic Number Scorecard - win rate, profit factor and drawdown per EA
Running several EAs on one account? This script groups the closed trades by magic number and shows the score of each EA: win rate, profit factor, net profit and drawdown. Read-only, writes a CSV file.
MACD Signals
Indicator edition for new platform.