Multi Rate Filter Bank
Dropping every Nth sample without filtering first is aliasing, not downsampling: frequency content above the new, lower Nyquist rate does not disappear, it folds back down into the visible band and becomes indistinguishable from genuine low-frequency structure. In practice this shows up as a "multi-timeframe" indicator whose higher-timeframe reading jitters in ways the real higher-timeframe bars never do - noise from the fine timeframe folding into what looks like real slow-timeframe structure. The fix is to low-pass filter at the NEW Nyquist rate first, so any content that would alias is removed before samples are ever dropped. The same logic runs in reverse for interpolation: zero-stuffing a series up to a higher rate creates spectral images that must be filtered out, not left in. The anti-aliasing/anti-imaging filter is a genuine windowed-sinc FIR low-pass kernel (Hamming window, unity DC gain), the standard way to design a linear-phase low-pass filter without an IIR design toolchain. MrfDecimate filters then subsamples; MrfInterpolate zero-stuffs then filters (scaling to restore the amplitude the zero-stuffing diluted); MrfResampleRational chains both to build a non-integer rate change (e.g. converting a 5-minute series to an approximate 3-minute grid is a 5/3 rate change: interpolate by 5, decimate by 3). Notes and limitations - Filtering uses direct-form convolution, not a polyphase implementation - correct and adequate for the tap counts and bar counts this library targets, at the cost of computing some filtered samples on decimation that immediately get discarded (a polyphase structure would skip that redundant work, at real implementation complexity this "Lite" library does not carry). - Edge handling replicates the boundary sample rather than zero-padding, avoiding an artificial pull toward zero at the start/end of a short price series - this is an approximation at the very edges, not exact filtering, and the first/last few output samples near a series boundary are the least trustworthy. - numTapsHint is rounded up to the next odd number internally (an odd tap count gives a symmetric kernel with a clean centre tap); more taps means a sharper, more accurate anti-aliasing cutoff at the cost of more computation and a longer filter transient at the edges. - This library does not resample to arbitrary/irrational ratios or align output to real MetaTrader higher-timeframe bar boundaries - it operates on a plain bar-indexed array, and building an M1-to-H1-style multi- timeframe bridge from it is a separate integration step for the caller.
Script · MT4 · v1.0 · Free
About Multi Rate Filter Bank
Multi Rate Filter Bank is a script for MetaTrader 4. It has 1 setting, such as Bars. MQL source code included.
Files in the download: MultiRateFilterBank.mqh, MultiRateFilterBank.txt, MultiRateFilterBankDemo.mq4.
Settings
| Setting | Default | What it does |
|---|---|---|
| Bars | 240 | length of the synthetic test series (must divide evenly by 4 and 12) |
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 → Scripts.
- 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 script onto a chart to run it once.
Tags: Multi-Timeframe (MTF) · MT4 Script · MQL4 Source Code