EKF Portfolio Trader is an institutional-grade automated trading system for MetaTrader 5 that applies the Extended Kalman Filter (EKF) a recursive Bayesian estimation algorithm, to dynamically track and predict price-state trajectories across an entire portfolio of instruments simultaneously.
Unlike conventional indicator-based EAs, this system treats price as a hidden state variable corrupted by measurement noise. The EKF continuously refines its estimate of the true underlying trend using prediction and update steps, producing statistically optimal, noise-filtered signals with quantified uncertainty (covariance). Trades are only entered when the filter's confidence meets a defined threshold, eliminating impulsive entries on random market noise.
It incorporates multi-symbol portfolio management, dynamic position sizing, real-time risk controls, and full MT5 compatibility, ready to deploy on forex, metals, indices, or any supported CFD instrument.
📡
EKF Signal Engine
Recursive state estimation with a 3-component model (price, velocity, acceleration). Tracks the true trend with covariance-bounded confidence, adapting in real time to changing volatility.
🗂️
Portfolio Mode
Manages multiple symbols from a single EA instance. Independent filter states per instrument with unified risk allocation and correlation filtering across the book.
📐
Z-Score Entry Gate
Trade signals are gated by the filter's normalized innovation z-score. Only statistically significant deviations from the predicted state trigger an entry.
🛡️
Layered Risk Controls
Dynamic lot sizing, daily loss circuit-breaker, max concurrent positions, pre-order margin verification via OrderCalcMargin, and free margin checks before every order.
🔄
Adaptive Noise Tuning
Process noise (Q) and measurement noise (R) matrices are fully exposed as inputs, letting you tune the filter between fast trend-following and smooth mean-reversion behavior.
📊
Full MT5 Compatibility
Strategy Tester ready with custom OnTester() criterion. Auto-detects symbol fill modes and supports both hedging and netting account types.
1
Predict On each new bar, the EKF projects the prior state estimate (price, velocity, acceleration) forward through the process model, inflating the covariance matrix according to Q.
2
Update The new price observation is compared against the prediction. The Kalman Gain balances trust between the model and the observation based on their relative uncertainties, then corrects the state estimate.
3
Signal Generation The normalized innovation z-score is calculated. If it exceeds the configured threshold and passes the trend, volume, and correlation filters, a directional signal is confirmed.
4
Safe Execution Before any order is sent, the EA verifies account balance, free margin, and uses OrderCalcMargin to confirm sufficient funds. Only then is the order dispatched with ATR-based SL/TP levels.