The kalman filter indicator borrows a method from control engineering. It keeps an estimate of where price really is, then corrects that estimate with each new close. How hard it corrects depends on two noise settings.
This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.
| Platforms | MT4 (.ex4) + MT5 (.ex5) |
|---|---|
| Chart window | Main price chart |
| Plots | 1: Kalman |
| Alerts | popup |
| Inputs | 4 |
What the Kalman Filter Indicator draws on the chart
One deep sky blue `Kalman` line sits directly on price.
No second line and no marks ship with this build.
The line updates on the forming bar as well as closed ones.
Nothing opens in a separate pane.
- Kalman: line, deep sky blue, width 2

How the Kalman Filter Indicator calculates its values
Gain decides how much to trust the new close
Each bar computes a gain from the running covariance and `InpR` `0.01`. The estimate moves toward the close by that fraction of the error. A larger gain follows price harder.
The two noise inputs pull opposite ways
`InpQ` `0.0001` is process noise, which says how much the underlying price is expected to drift. `InpR` `0.01` is measurement noise, which says how much to distrust any single close. Their ratio sets the smoothing.
Covariance settles quickly
`InpInitialP` `1.0` only matters for the first few bars. After that the covariance converges to a steady value, so the line behaves consistently across the rest of the history.
How to read the signals
The line is an estimate of price, not an average of it.
A wide gap between price and the line means recent closes surprised the estimate.
Raising `InpR` makes the line calmer and slower.
Raising `InpQ` does the opposite and lets it chase price.
Alert channels in this build: popup, one message per closed bar.
Just one route exists, and it starts switched off. `InpAlertOnX` `false` means nothing fires until you enable it. Once on, a terminal message appears when price crosses the line on a closed bar. No phone, mail or sound option ships here.
Every Kalman Filter Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
InpQ |
Process noise Q. Process noise, how much drift the estimate expects, default `0.0001`. | 0.0001 |
InpR |
Measurement noise R. Measurement noise, how much a single close gets distrusted, default `0.01`. | 0.01 |
InpInitialP |
Initial estimate covariance P. Starting covariance, which matters only at the start, default `1.0`. | 1.0 |
Alert settings
| Setting | What it does | Default |
|---|---|---|
InpAlertOnX |
Alert on price/Kalman cross (closed bar). Message when price crosses the line on a closed bar, default `false`. | off |

Settings that fit your chart
The ratio between the two noise settings matters more than the chart. EURUSD H1 is the reference chart, where the defaults give a line close to a medium average. On M1 you will want a higher `InpR`. Daily bars suit the defaults well.
When the Kalman Filter Indicator fails
A one-dimensional filter models level only, so it has no view on trend or velocity.
The defaults are a ratio, and that ratio suits some instruments better than others.
Nothing marks a signal, so a rule has to come from you.
Copy the compiled Kalman Filter Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.
Background reading on the method behind the Kalman Filter Indicator: External financing on Wikipedia, Crossrate at Investopedia.
Download the Kalman Filter Indicator for MT4 and MT5
The zip holds the compiled Kalman Filter Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.
Download this indicator free
Enter your email and the file is yours. You also get the full MT4 and MT5 library.
FAQ
What does InpR 0.01 represent?
Measurement noise, meaning how much the filter distrusts any single close. Raising it tells the filter that closes are unreliable, so the line leans on its own past estimate and smooths out. Lowering it makes the line hug price.
How does InpQ 0.0001 differ from InpR?
It is process noise, describing how much the underlying price is expected to move on its own. The two pull in opposite directions, and only their ratio matters, so changing both by the same factor changes nothing.
Does InpInitialP 1.0 affect the whole line?
No, only the first handful of bars. The covariance converges to a steady value very quickly, after which the starting figure has no influence at all on what you see.
Is the Kalman plot a moving average?
Not in the usual sense. An average weights a fixed window of past closes. This keeps a single running estimate and corrects it by a gain each bar, which is why it has no period input at all.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Kalman Filter Indicator as one input. Always backtest before trading live.
Category: this is part of our Signal and Forecast collection. Also, browse more Signal and Forecast for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.
External references
- Learn more about the underlying method in External financing on Wikipedia.
- For wider market background, see Crossrate at Investopedia.
