Loading…

Modular Signal Filter Framework

A signal that fires correctly is only half the problem; whether it fires into a session with no liquidity, against the prevailing trend, during a spread spike, or on a day you have already decided to sit out is the other half, and most published EAs bury that logic inline where it cannot be turned on and off independently. This template pulls it out into five separate filter functions, each with its own enable switch and its own inputs, called in a fixed pipeline that reports every filter's individual verdict. MQL4 has no function pointers or delegates, so "modular" here means each filter has the identical shape - read its own inputs, judge the current state or the signal direction, return pass or block - and knows nothing about the others. Adding a sixth filter means writing one more function in that shape and adding one line to PassesAllFilters(); no filter needs to change when another is added, removed or reordered. When a signal is blocked, the on-chart panel and the Experts log both show the full per-filter breakdown - pass, block, or skipped if that filter is disabled - so tuning which filter is too strict does not require guesswork. The fast/slow moving average cross wired up as DetectRawSignal() is a placeholder only; the filter pipeline is the reusable part and works identically regardless of what raw condition feeds it. Notes and limitations - The pipeline short-circuits its final pass/fail verdict on the first block for the trading decision, but the report always evaluates and shows every filter's individual result, so a blocked signal never hides which other filters would also have blocked it. - All five filters are placeholders in the sense that their thresholds are generic; the trend and volatility filters in particular should be tuned to the instrument and timeframe actually traded before relying on them. - The day-of-week filter blocks unconditionally on a weekend, since no session exists to evaluate. - On MQL5 with a netting account, a demo order is refused (not queued or retried) whenever the chart's symbol already carries a foreign-magic position - see MQL4 VERSUS MQL5 DIFFERENCES above.

Expert advisor · MT5 · v1.0 · Free

About Modular Signal Filter Framework

Modular Signal Filter Framework is an expert advisor (trading robot) for MetaTrader 5 based on Moving Average and ATR. It trades only in the hours you set (time filter). It has 25 settings, such as Fast ma period, Slow ma period and Use session filter. MQL source code included.

Files in the download: SignalFilterFramework.ex5, SignalFilterFramework.mq5, SignalFilterFramework.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Fast ma period10Fast MA period for the placeholder signal
Slow ma period30Slow MA period for the placeholder signal
Use session filtertrueOnly allow signals inside a server-time hour window
Session start hour7Session start, server time, 0-23
Session end hour20Session end, server time, 0-23 (exclusive)
Use spread filtertrueBlock signals when the spread is too wide
Max spread pips3.0Maximum acceptable spread, pips
Use trend filtertrueOnly allow signals that agree with the longer trend
Trend ma period100MA period defining the longer trend
Use volatility filtertrueBlock signals when volatility is outside a sane range
Atr period14ATR period for the volatility filter
Min atr pips3.0Below this ATR, the market is judged too quiet to trade
Max atr pips60.0Above this ATR, the market is judged too wild to trade
Use day filterfalseBlock signals on specific weekdays
Allow mondaytrue
Allow tuesdaytrue
Allow wednesdaytrue
Allow thursdaytrue
Allow fridaytrue
Enable tradingfalseOff by default - place a demo order when a signal clears every filter
Lots0.01Lot size for the demo entry
Stop loss pips30Stop loss distance, in pips
Slippage pips3Slippage tolerance, in pips
Max retries5Trade-send attempts before giving up
Magic20261303Magic number this EA tags its own orders with

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Buy/Sell Arrows · Trend · Trading Sessions · Time Filter · Moving Average · ATR · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria