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.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
FibonacciFlux: Pushing indicator boundaries. Crafting sophisticated, surprising tools via ambitious R&D.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
FibonacciFlux: Pushing indicator boundaries. Crafting sophisticated, surprising tools via ambitious R&D.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.