מעודכן
Kalman Z-Score & Value Bands [UkutaLabs]

Kalman Z-Score & Value Bands tracks a Kalman filter "value line" through price and measures how far price is stretched from it, on the chart's timeframe and on up to five higher timeframes at once.
HOW IT WORKS
Value line
The line comes from a two-state Kalman filter that estimates both the price level and its slope each bar. Because it models slope, it follows trends more closely than a moving average of similar smoothness. Smoothing is set as an EMA-equivalent length: Smoothing 20 gives a line about as smooth as a 20-bar EMA.
Z-score and bands
The z-score is the distance between price and the value line, divided by the typical size of that distance over the Lookback period (root mean square of the residuals). 0 means price is on the line; +2 means price is two typical distances above it. The bands on the price chart sit at +/- Threshold, so a close touching a band is exactly z = +/- Threshold. Because the scale adapts to recent behaviour, one threshold works in quiet and volatile conditions and across instruments.
Bias: rising, falling or flat
The line is colored by its direction. Slope is measured as how far the line moves over one Smoothing period in z-score units, and anything inside the Flat Zone counts as flat, so sideways markets read as flat instead of flipping between up and down.
Bias Mode decides how direction is read:
- Slope: from the line's slope alone. Steady in trends, but it keeps the old direction for a while after a move stops.
- Slope + Price: also requires price to stay on the same side of the line, so the bias turns flat soon after a move stalls.
By default the chart timeframe uses Slope + Price and higher timeframes use Slope, giving a quick read on the chart and a steady read on the bigger picture.
HOW TO READ IT
- Z-score bars take the bias color (rising, falling, flat). They are faded inside the threshold and solid beyond it.
- A sloped line with z beyond the threshold in the same direction is a strong trend, not an automatic fade.
- With a rising line, pullbacks toward the line are the areas of interest; with a falling line, rallies toward it. With a flat line, stretches beyond the threshold that return inside are the mean-reversion setups.
- Bias Timeframe lets the z-score bars take their color from a higher timeframe, so a lower timeframe can be read against a higher timeframe direction.
DASHBOARD
Turn on Show Dashboard for a table on the price chart showing the chart timeframe plus 5m, 15m, 30m, 60m and 240m: bias, z-score and state (Stretched beyond the threshold, Returning on the bar it comes back inside), with an up/flat/down count across all rows. Only timeframes higher than the chart are shown.
ALERTS
Stretched Above, Stretched Below, Return From Above, Return From Below, Bias Turned Up, Bias Turned Down. Set alerts to Once Per Bar Close.
SETTINGS
Smoothing (20), Lookback (50), Threshold (2), Flat Zone (1), Bias Mode, HTF Bias Mode, Bias Timeframe, colors, value line and band display, dashboard timeframes, position and font size.
NOTES
- Values are calculated from closed bars. The open bar updates until it closes; closed bars do not repaint.
- Higher timeframe values use the last closed bar of that timeframe, so they change only after that bar closes.
- Earnings gaps and other news-driven jumps can push the z-score far beyond the threshold. That reflects the gap, not a gradual stretch.
- This is an analysis tool, not a trading system. Test any approach before trading it.
HOW IT WORKS
Value line
The line comes from a two-state Kalman filter that estimates both the price level and its slope each bar. Because it models slope, it follows trends more closely than a moving average of similar smoothness. Smoothing is set as an EMA-equivalent length: Smoothing 20 gives a line about as smooth as a 20-bar EMA.
Z-score and bands
The z-score is the distance between price and the value line, divided by the typical size of that distance over the Lookback period (root mean square of the residuals). 0 means price is on the line; +2 means price is two typical distances above it. The bands on the price chart sit at +/- Threshold, so a close touching a band is exactly z = +/- Threshold. Because the scale adapts to recent behaviour, one threshold works in quiet and volatile conditions and across instruments.
Bias: rising, falling or flat
The line is colored by its direction. Slope is measured as how far the line moves over one Smoothing period in z-score units, and anything inside the Flat Zone counts as flat, so sideways markets read as flat instead of flipping between up and down.
Bias Mode decides how direction is read:
- Slope: from the line's slope alone. Steady in trends, but it keeps the old direction for a while after a move stops.
- Slope + Price: also requires price to stay on the same side of the line, so the bias turns flat soon after a move stalls.
By default the chart timeframe uses Slope + Price and higher timeframes use Slope, giving a quick read on the chart and a steady read on the bigger picture.
HOW TO READ IT
- Z-score bars take the bias color (rising, falling, flat). They are faded inside the threshold and solid beyond it.
- A sloped line with z beyond the threshold in the same direction is a strong trend, not an automatic fade.
- With a rising line, pullbacks toward the line are the areas of interest; with a falling line, rallies toward it. With a flat line, stretches beyond the threshold that return inside are the mean-reversion setups.
- Bias Timeframe lets the z-score bars take their color from a higher timeframe, so a lower timeframe can be read against a higher timeframe direction.
DASHBOARD
Turn on Show Dashboard for a table on the price chart showing the chart timeframe plus 5m, 15m, 30m, 60m and 240m: bias, z-score and state (Stretched beyond the threshold, Returning on the bar it comes back inside), with an up/flat/down count across all rows. Only timeframes higher than the chart are shown.
ALERTS
Stretched Above, Stretched Below, Return From Above, Return From Below, Bias Turned Up, Bias Turned Down. Set alerts to Once Per Bar Close.
SETTINGS
Smoothing (20), Lookback (50), Threshold (2), Flat Zone (1), Bias Mode, HTF Bias Mode, Bias Timeframe, colors, value line and band display, dashboard timeframes, position and font size.
NOTES
- Values are calculated from closed bars. The open bar updates until it closes; closed bars do not repaint.
- Higher timeframe values use the last closed bar of that timeframe, so they change only after that bar closes.
- Earnings gaps and other news-driven jumps can push the z-score far beyond the threshold. That reflects the gap, not a gradual stretch.
- This is an analysis tool, not a trading system. Test any approach before trading it.
הערות שחרור
Minor code cleanupהערות שחרור
New: a Daily row in the multi-timeframe dashboard, below 240m. It shows the daily Kalman bias, z-score and state alongside your intraday timeframes, so you can see the bigger picture at a glance.The daily row uses the last closed daily bar, so its reading updates once a day and never changes mid-session.
It's on by default and only appears on intraday charts. To hide it, untick Daily Row at the bottom of the Dashboard settings.
Your saved settings are unchanged, and the dashboard itself is still off until you enable Show Dashboard.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.