OPEN-SOURCE SCRIPT
Kalman Trend Estimator [KTE] -FibonacciFlux

OVERVIEW
Optimal linear trend filter using scalar Kalman filtering. Treats price as a noisy
measurement of a hidden trend state and recursively computes the optimal estimate. The Kalman
gain adapts automatically — no manual threshold tuning required.
HOW IT WORKS
The filter balances two noise sources:
- Process Noise (Q): how fast the true trend can change
- Measurement Noise (R): how noisy price observations are
The Kalman gain adjusts every bar:
- During clean trends: gain tightens, tracks price closely
- During choppy markets: gain loosens, smooths out noise
Innovation magnitude (prediction error) serves as a built-in regime classifier: small
innovations = trending, large innovations = noisy/ranging.
FEATURES
- Adaptive Kalman gain — zero manual tuning
- Innovation-based regime coloring (green = trend, red = noise)
- Confidence bands derived from estimation uncertainty (P matrix)
- Signal dots at trend direction changes
- Works on all timeframes and instruments
SETTINGS
Process Noise Q: Controls trend tracking speed. Higher = faster adaptation. Default 0.01.
Measurement Noise R: Controls price smoothing. Higher = smoother output. Default 1.0.
Show Bands: Toggle confidence bands on/off.
Based on: R.E. Kalman (1960), "A New Approach to Linear Filtering and Prediction Problems",
Journal of Basic Engineering.
Optimal linear trend filter using scalar Kalman filtering. Treats price as a noisy
measurement of a hidden trend state and recursively computes the optimal estimate. The Kalman
gain adapts automatically — no manual threshold tuning required.
HOW IT WORKS
The filter balances two noise sources:
- Process Noise (Q): how fast the true trend can change
- Measurement Noise (R): how noisy price observations are
The Kalman gain adjusts every bar:
- During clean trends: gain tightens, tracks price closely
- During choppy markets: gain loosens, smooths out noise
Innovation magnitude (prediction error) serves as a built-in regime classifier: small
innovations = trending, large innovations = noisy/ranging.
FEATURES
- Adaptive Kalman gain — zero manual tuning
- Innovation-based regime coloring (green = trend, red = noise)
- Confidence bands derived from estimation uncertainty (P matrix)
- Signal dots at trend direction changes
- Works on all timeframes and instruments
SETTINGS
Process Noise Q: Controls trend tracking speed. Higher = faster adaptation. Default 0.01.
Measurement Noise R: Controls price smoothing. Higher = smoother output. Default 1.0.
Show Bands: Toggle confidence bands on/off.
Based on: R.E. Kalman (1960), "A New Approach to Linear Filtering and Prediction Problems",
Journal of Basic Engineering.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
FibonacciFlux: Pushing indicator boundaries. Crafting sophisticated, surprising tools via ambitious R&D.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
FibonacciFlux: Pushing indicator boundaries. Crafting sophisticated, surprising tools via ambitious R&D.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.