Regime Filtered Signal Overlay
"Only trade this signal when the market is trending" is common advice, but it is rarely checked with an actual number. This overlay plots a Close-vs-SMA cross signal twice on the same chart: small grey arrows for every cross, and larger coloured arrows for the subset that fired while ADX(InpAdxPeriod) was above InpAdxThreshold at that bar - the regime filter. Both sets are visible together so it is obvious which crosses the filter discards, not just how many are left. The historical hit rate for each set - the percentage of crosses whose price moved in the expected direction over the next InpLookaheadBars bars - is computed separately and printed as an on-chart comment, along with the plain percentage-point difference between them. A filter that looks sensible but produces a smaller or unchanged hit rate on the actual instrument being charted is a genuinely useful negative result, and this tool reports that outcome exactly as honestly as a positive one. ADX above a fixed threshold is a well-understood, ordinary regime definition, used here deliberately rather than a novel one - the point of this tool is measuring the effect of a regime filter, not inventing a new way to define a regime. Notes and limitations - Non-repainting: arrows are placed on confirmed crosses using completed bar values, and ADX is read at that same confirmed bar. - The hit-rate table only scores crosses old enough that InpLookaheadBars have already elapsed, so the most recent signals near the current bar are correctly excluded until their outcome is known. - The regime definition (ADX above a fixed threshold) is a common, simple one; a different regime definition (volatility-based, session-based, etc.) would need its own comparison logic, not a parameter change here. - The Close-vs-SMA cross is a placeholder base rule; the side-by-side filtered/unfiltered comparison and hit-rate scoring applies to any directional signal.
Indicator · MT4 · v1.0 · Free
About Regime Filtered Signal Overlay
Regime Filtered Signal Overlay is an indicator for MetaTrader 4 based on Moving Average and ADX. It draws buy and sell arrows on the chart. It has 5 settings, such as Ma period, Adx period and Adx threshold. MQL source code included.
Files in the download: RegimeFilteredSignals.mq4, RegimeFilteredSignals.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Ma period | 20 | SMA period the base rule crosses against |
| Adx period | 14 | ADX period used as the regime filter |
| Adx threshold | 25.0 | ADX must be above this to count as "trending" |
| Lookahead bars | 10 | Bars ahead used to score hit-rate for each set |
| Stats lookback bars | 3000 | How many recent bars are scanned to build the hit-rate table |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: Moving Average · ADX · Buy/Sell Arrows · Trend · MT4 Indicator · MQL4 Source Code