Discussing the article: "Feature Engineering for ML (Part 2): Implementing Fixed-Width Fractional Differentiation in MQL5"
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: Feature Engineering for ML (Part 2): Implementing Fixed-Width Fractional Differentiation in MQL5.
This article delivers a production-grade MQL5 implementation of fixed-width fractional differentiation for live MetaTrader 5 feeds. We introduce a header-only CFFDEngine that precomputes weights without a fixed cap, performs O(width) per-bar updates, and avoids per-tick allocations. The FFD.mq5 indicator supports all ENUM_APPLIED_PRICE types and prev_calculated optimization. Validation scripts confirm numerical equivalence with the standard Python frac diff_ffd pipeline.
Part 1 developed the theory and Python implementation of fractional differentiation using the fixed-width window (FFD) method from Chapter 5 of AFML. Three properties of the FFD method make it ideal for live deployment: the weight vector is precomputed once, each observation depends on a bounded lookback window, and the computation is a single dot product. This article translates those properties into a production-grade MQL5 engine that runs efficiently on live MetaTrader 5 data feeds.
The implementation has two components: CFFDEngine (a header-only .mqh class for weight generation and dot-product computation) and FFD.mq5 (a custom indicator that wraps CFFDEngine and draws the fractionally differentiated series). The indicator supports MetaTrader's prev_calculated optimization and recomputes only what has changed since the last call.
The design goal throughout is: zero per-tick allocation, O(width) per new bar, and O(1) initialization amortized. On a typical instrument with d = 0.4 and τ = 10−5, the threshold-determined window width is 1457 bars. At τ = 10−4 it falls to 281 bars. The dot product over that window completes in microseconds on modern hardware.
Author: Patrick Murimi Njoroge