OPEN-SOURCE SCRIPT

Kalman Trend Estimator [KTE] -FibonacciFlux

1 011
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.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.