Patrick Murimi Njoroge / Publications
Codes
TransactionCostCollector — Broker Cost Profiling Script for MetaTrader 5
Triple-barrier labeling pipelines frequently use an arbitrary constant (0.5–1.0%) or a legacy spread assumption as the min_ret threshold. A threshold set below the actual round-trip transaction cost causes the pipeline to label cost-driven noise as tradeable signal. The labeled dataset then
Fixed-Width Fractional Differencing (FFD) for MetaTrader 5
MQL5 implementation of the fixed-width fractional differencing (FFD) method from López de Prado's Advances in Financial Machine Learning (Chapter 5). Transforms a non-stationary price series into a stationary one while preserving maximum historical memory; output cross-validates against the Python
Articles
MetaTrader 5 Machine Learning Blueprint (Part 22): Auditing the Selection Criterion — Measuring Overfit in Hyperparameter Search for MetaTrader 5
We show that nested cross-validation removes optimistic evaluation bias but does not stop hyperparameter search from overfitting a finite sample, and we add a diagnostic for when the criterion cannot resolve candidates from noise. We implement OffsetPurgedKFold (boundary-shifted repartitioning), a
Meta-Labeling the Classics (Part 4): Filtering and Sizing MACD Trades for MetaTrader 5
MACD signal-line crossovers often reflect range noise rather than true momentum shifts, producing whipsaws. We apply a two-layer meta-labeling pipeline with an Optuna-optimized regime gate to filter entries on EURUSD H1, turning a gross-losing rule into a positive but not statistically significant
MetaTrader 5 Machine Learning Blueprint (Part 21): Feature Importance Analysis for MetaTrader 5
Feature importance often understates correlated predictors by spreading one signal across many engineered copies, while unrelated noise can appear higher. We measure this effect against a known ground truth and compare four remedies: permutation importance with purged cross-validation
Machine Learning Under Constraint (Part 2): Calibrating Position Size to the Remaining Drawdown Budget for MetaTrader 5
We present a rule-set-aware calibration chain that turns the remaining risk budget into a calibrated sigmoid scale for position sizing. It computes a ceiling from stop loss pct and safety factor, back-solves w at a reference divergence, and flattens size progressively as the budget shrinks. The
Machine Learning Under Constraint (Part 1): A Configurable Rule Set for Prop-Firm Position Sizing for MetaTrader 5
Hardcoded prop-firm rules lock the sizer to one program. This article factors those rules into a PropFirmRuleSet and refactors PropFirmAccountState and the sizing modifiers to consume it, including dynamic versus fixed daily limits and the news-window profit-credit haircut. Parity against the
MetaTrader 5 Machine Learning Blueprint (Part 20): Denoising, Detoning, and Clustering the Feature Correlation Matrix for MetaTrader 5
Raw feature correlations contain estimation noise and a shared market-mode component that distort clustering. We fit the Marcenko–Pastur noise ceiling (with an effective sample size correction), apply constant-residual denoising and market detonation, and run the Optimal Number of Clusters routine
Meta-Labeling the Classics (Part 3): Filtering and Sizing Bollinger Band Trades for MetaTrader 5
Bollinger Band mean reversion degrades in trending regimes when ADX is high and bandwidth expands. We separate direction from trade selection with a two‑stage meta‑labeling pipeline: a gradient‑boosted secondary classifier trained with PurgedKFold on band‑specific features (BBP, BBB, bandwidth
Feature Engineering for ML (Part 14): Trend-Scanning Features in MQL5 for MetaTrader 5
A naive MQL5 port of trend-scanning features recomputes each candidate window per bar at O(H·L) cost. This article introduces CTrendScanningFeatures.mqh, which maintains three running sums per horizon and updates them in O(1) per bar, verified against a Python reference. The indicator exposes four
Feature Engineering for ML (Part 13): Trend-Scanning Features in Python for MetaTrader 5
Trend-scanning supports both forward and backward windows, and the labeling default is unsafe for features: it looks ahead and boosts next-bar agreement well above chance on random walks. We provide a dedicated wrapper, get trend scanning features, that forces computational causal and returns only
Feature Engineering for ML (Part 12): Fractal Features in MQL5 for MetaTrader 5
A direct MQL5 port of the fractal detector writes each pattern at its center bar, so a buffer read by an expert advisor holds a value that only existed n bars later. We implement CFractalFeatures.mqh with ProcessBar for bar-by-bar use and Compute for full-series recalculation, covering detection
Forum
Article Notifications
Hello, I have been wondering if notifications for article writing could be arranged so that all alerts regarding one article are grouped. It would make it easier to parse when one has multiple articles in progress and reduce unseen messages











