OPEN-SOURCE SCRIPT

Kalman Hull Kijun [BackQuant]

251
Kalman Hull Kijun [BackQuant]
A trend baseline that merges three ideas into one clean overlay, Kalman filtering for noise control, Hull-style responsiveness, and a Kijun-like Donchian midline for structure and bias.

Context and lineage
This indicator sits in the same family as two related scripts:
  • Kalman Price Filter [BackQuant]
    Kalman Price Filter [BackQuant]
    This is the foundational building block. It introduces the Kalman filter concept, a state-estimation algorithm designed to infer an underlying “true” signal from noisy measurements, originally used in aerospace guidance and later adopted across robotics, economics, and markets.
  • Kalman Hull Supertrend [BackQuant]
    Kalman Hull Supertrend [BackQuant]
    This is the original script made, which people loved. So it inspired me to create this one.


Kalman Hull Kijun uses the same core philosophy as the Supertrend variant, but instead of building a Supertrend band system, it produces a single structural baseline that behaves like a Kijun-style reference line.

What this indicator is trying to solve
Most trend baselines sit on a bad trade-off curve:
  • If you smooth hard, the line reacts late and misses turns.
  • If you react fast, the line whipsaws and tracks noise.


Kalman Hull Kijun is designed to land closer to the middle:
  • Cleaner than typical fast moving averages in chop.
  • More responsive than slow averages in directional phases.
  • More “structure aware” than pure averages because the baseline is range-derived (Kijun-like) after filtering.


Core idea in plain language
The plotted line is a Kijun-like baseline, but it is not built from raw candles directly.

High level flow:
  • Start with a chosen price stream (source input).
  • Reduce measurement noise using Kalman-style state estimation.
  • Add Hull-style responsiveness so the filtered stream stays usable for trend work.
  • Build a Kijun-like baseline by taking a Donchian midpoint of that filtered stream over the base period.


So the output is a single baseline that is intended to be:
  • Less jittery than a simple fast MA.
  • Less laggy than a slow MA.
  • More “range anchored” than standard smoothing lines.


How to read it

1) Trend and bias (the primary use)
  • Price above the baseline, bullish bias.
  • Price below the baseline, bearish bias.
  • Clean flips across the baseline are regime changes, especially when followed by a hold or retest.


2) Retests and dynamic structure
Treat the baseline like dynamic S/R rather than a signal generator:
  • In uptrends, pullbacks that respect the baseline can act as continuation context.
  • In downtrends, reclaim failures around the baseline can act as continuation context.
  • Repeated back-and-forth around the line usually means compression or chop, not clean trend.


3) Extension vs compression (using the fill)
The fill is meant to communicate “distance” and “pressure” visually:
  • Large separation between price and baseline suggests expansion.
  • Price compressing into the baseline suggests rebalancing and decision points.


Inputs and what they change

Kijun Base Period
  • Controls the structural memory of the baseline.
  • Higher values track broader swings and reduce flips.
  • Lower values track tighter swings and react faster.


Kalman Price Source
  • Defines what data the filter is estimating.
  • Close is usually the cleanest default.
  • HL2 often “feels” smoother as an average price.
  • High/Low sources can become more reactive and less stable depending on the market.


Measurement Noise
Think of this as the main smoothness knob:
  • Higher values generally produce a calmer filtered stream.
  • Lower values generally produce a faster, more reactive stream.


Process Noise
Think of this as adaptability:
  • Higher values adapt faster to changing conditions but can get twitchy.
  • Lower values adapt slower but stay stable.


Plotting and UI (what you see on chart)

1) Adaptive line coloring
  • Baseline turns bullish color when price is above it.
  • Baseline turns bearish color when price is below it.
  • This makes the state readable without extra panels.


2) Gradient “energy” fill
  • Bull fill appears between price and baseline when above.
  • Bear fill appears between price and baseline when below.
  • The goal is clarity on separation and control, not decoration.


3) Rim effect
  • A subtle band around price that only appears on the active side.
  • Helps highlight directional control without hiding candles.


4) Candle painting (optional)
  • Candles can be colored to match the current bias.
  • Useful for scanning many charts quickly.
  • Disable if you prefer raw candles.


Alerts
  • Long state alert when price is above the baseline.
  • Short state alert when price is below the baseline.
  • Best used as a bias or regime notification, not a standalone entry trigger.


Where it fits in a workflow
This is a context layer, it pairs well with:
  • Market structure tools, BOS/MSB, OBs, FVGs.
  • Momentum triggers that need a regime filter.
  • Mean reversion tools that need “do not fade trends” context.


Limitations
  • No baseline eliminates chop whipsaws, tuning only manages the trade-off.
  • Settings should not be copy pasted across assets without checking behavior.
  • This does not forecast, it estimates and smooths state, then expresses it as a structural baseline.


Disclaimer
  • Educational and informational only, not financial advice.
  • Not a complete trading system.
  • If you use it in any trading workflow, do proper backtesting, forward testing, and risk management before any live execution.

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。