Discussing the article: "Using the MQL5 Economic Calendar for News Filter (Part 6): A Filter an EA Can Hold Two Of"

Check out the new article: Using the MQL5 Economic Calendar for News Filter (Part 6): A Filter an EA Can Hold Two Of.

This article describes refactoring an EA‑scoped news filter into a reusable MQL5 class. Inputs move into a configuration struct, while events, currency mapping, saved stops, a suspension flag, and a private CTrade object become per‑instance state. The class lets one EA run multiple filters with different thresholds and responses, share one rule table, and reduce duplicated code while keeping each filter independently configurable.

The news filter built so far reads the broker's calendar when the EA trades live and a CSV file when the Strategy Tester drives it; it gives the releases named in a rule table more room than the calendar's importance tag alone would, blocks entries, closes positions, suspends and restores stops, and keeps a suspension across a terminal restart. Apart from the tier scale and the rule table, which the previous part moved into two headers, all of it sits at file scope in one Expert Advisor. This is manageable as long as you have only one EA. Putting the same protection into a second EA means copying most of the file and maintaining two versions. A fix in one can leave the other unchanged.

The obvious step is to create a header: move the news code into a.mqh file and include it so the logic becomes shareable. This is a necessary step, and for an EA that holds one filter it can be enough. It doesn't solve the case where one EA needs two filters with different settings. Each filter needs its own settings and its own state, and moving code into a header provides neither. By the end of this part, the EA will:

This part changes how the filter is packaged. It adds no new detection behavior, tier, window rule, or responses, so for the same events and settings a filter gives the same answer to whether a news window is open. That answer is what this article means by the filter's decision. What differs from the previous EA is described where its code is shown. The main differences are how stops are suspended, saved, and restored, what a filter reports when it cannot detect anything, and what the EA in this part does with that report. Two files:

Author: Solomon Anietie Sunday