Blog / Strategy
Strategy

Kalman Velocity Trend

Disclaimer: This article is for educational and informational purposes only. It does not constitute financial or investment advice. Trading forex and CFDs carries significant risk of loss. Past performance of any strategy — including backtests — does not guarantee future results. Never trade with money you cannot afford to lose.

What Is This Strategy?

Kalman Velocity Trend is a trend-pullback strategy built around a 2-state Kalman filter, a recursive estimation technique borrowed from aerospace and signal processing that separates a noisy signal into its underlying state and rate of change. Rather than relying on a conventional moving average — which only produces a smoothed price level and infers its slope with lag — this strategy estimates two hidden quantities of the market at once: a filtered level (the market's "fair" price) and a velocity (how fast that price is changing per bar). The velocity term is the heart of the approach: it is a directly-estimated, noise-reduced measure of trend slope that can turn before a lagging moving-average slope does.

The strategy is designed for trending market conditions with periodic pullbacks. It uses the sign of the estimated velocity to decide which direction it is allowed to trade, and it waits for price to dip back toward the filtered level and then reclaim it before entering. In other words, it is built to buy dips inside uptrends and sell rallies inside downtrends, rather than chasing extended moves. When velocity is small — a flat, directionless market — the strategy simply stays out.

As a learning tool, Kalman Velocity Trend suits traders who want to move beyond simple moving-average crossovers and understand how state-space filtering can be applied to price. It is a clean, single-timeframe example of noise-adaptive estimation: every noise setting is expressed as a fraction of the Average True Range (ATR), so the same parameters adapt to each symbol's own volatility. This makes it a useful study piece for anyone curious about adaptive filters, regime detection, and disciplined pullback entries.

How It Works

The strategy processes one completed candle at a time on your chosen timeframe. On each newly closed bar it updates the Kalman filter, checks whether a trend and a pullback are both present, and then manages positions accordingly.

Kalman velocity trend MT5 EA
Illustrative example of the strategy’s entry and exit logic — not real trading results.

Strategy Parameters

Parameter Default Min Max Description
ProcNoiseFrac 0.10 0.02 0.50 Process-noise sigma as a fraction of ATR. Larger values make the filter trust its own model less and react faster to price, producing a more responsive velocity estimate.
MeasNoiseFrac 1.00 0.25 3.00 Measurement-noise sigma as a fraction of ATR. Larger values make the filter trust each closing price less and smooth harder, producing a steadier but slower velocity.
VelThreshFrac 0.05 0.00 0.30 Trend gate. The required absolute velocity, as a fraction of ATR, before any trade is allowed. Higher values demand a stronger trend before acting.
AtrPeriod 14 7 30 Length of the ATR used for noise scaling, the trend gate, and stop/target distances.
AtrSlMult 2.0 1.0 5.0 Stop-loss distance as a multiple of ATR (entry −/+ AtrSlMult × ATR).
AtrTpMult 3.0 1.0 8.0 Take-profit distance as a multiple of ATR (entry +/− AtrTpMult × ATR).
Lots 0.10 0.01 1.0 Fixed lot size used for each position.

The strategy also uses a Magic number (default 4130) to identify and manage only its own positions, keeping it isolated from manual trades or other Expert Advisors on the same account.

Kalman velocity trend MT5 EA — MQL5 source code

Recommended Chart Settings

Kalman Velocity Trend is a single-timeframe strategy: every calculation uses the chart's own timeframe, so it runs on whatever timeframe you attach it to. A common starting point for study is a major forex pair such as EUR/USD on the H1 (1-hour) timeframe, which offers reasonable liquidity and enough trend structure for the pullback logic to be meaningful. The ATR-based noise scaling means the same defaults can be explored across other liquid pairs and timeframes as well.

Because the filter and its noise settings adapt to each instrument's volatility, no per-symbol re-tuning of raw variances is strictly required. That said, results will vary considerably across different symbols, sessions, and market conditions. Always test any configuration on historical data and a demo account before drawing conclusions.

How to Install on MetaTrader 5

What to Consider Before Using This EA

Strengths. The main advantage of this approach is that velocity is estimated directly rather than inferred from a lagging moving-average slope, so the trend gate can respond earlier and more cleanly. The pullback-reclaim entry adds discipline: it favours entering on retracements into a trend rather than chasing extension, which historically tends to improve entry location. The ATR-based noise scaling and stops give the strategy a degree of built-in adaptability across instruments, and the small, broadly-ranged parameter set reduces the temptation to over-fit.

Limitations. Like all trend-following logic, Kalman Velocity Trend can struggle in range-bound or choppy markets, where velocity flickers around the threshold and pullback reclaims produce whipsaw entries that are quickly stopped out. The constant-velocity model assumes trends persist in a roughly linear fashion; sharp reversals, gaps, or news-driven spikes can violate that assumption and produce late exits. Fixed-lot sizing does not scale risk to account equity, and the fixed ATR take-profit may cut winning trends short during strong, extended moves. It is also a fully mechanical system with no news filter or session filter.

Treat this EA as an educational framework for studying state-space filtering and pullback entries — not as a finished, ready-to-deploy product. Understanding why it enters and exits is far more valuable than the raw signals themselves.

Risk Management Tips

Risk Warning

Trading foreign exchange, CFDs, and other leveraged financial instruments involves substantial risk of loss and is not suitable for all investors. The strategies and tools discussed on this page are provided for educational purposes only and do not constitute financial advice, investment recommendations, or solicitation to trade. Always consult a qualified financial adviser before making trading decisions. Past backtest performance is not indicative of future results.

Downloads

← Back to Blog