Nadaraya-Watson Envelope explained: settings and repainting
The Nadaraya-Watson Envelope on TradingView is LuxAlgo's open-source script, one of the most-boosted indicators on the platform. It draws a smooth curve through price with a band above and below, and triangles where price pokes outside the band. This page explains what it calculates, from the published code, and answers the question its audience keeps asking: does it repaint?
Short answer: in its default setting, yes, by design. The script has a second mode that does not repaint on closed bars, and it looks noticeably different.
What "8, 3, close" means
The script has three main settings, and the defaults are why people search for "8 3 close":
- Bandwidth (8): how wide the averaging window is. Each bar's value is a weighted average of nearby bars, with weights that fall off in a bell curve. At 8, a bar 8 bars away counts about 61% as much as the centre bar, 16 bars away about 14%, and 24 bars away about 1%. Raise it for a smoother, slower curve; lower it for one that hugs price.
- Multiplier (3): how far the band sits from the curve, in units of the average distance between price and the curve. 3 means three times that average gap.
- Source (close): the price the curve is built from.
There is also a fourth input, Repainting Smoothing, and it is switched on by default.
Why the default mode repaints
A Nadaraya-Watson estimator is a kernel regression: a smoothed value at each point, made from a weighted average of the points around it, on both sides.
In the default mode the script recalculates the whole curve on the latest bar. For every bar in the last 500, it averages the bars before it and the bars after it. A point from two weeks ago is smoothed using prices from the days that followed. That is why the curve turns so neatly at tops and bottoms: it already knows what came next.
Two things follow:
- The recent part of the curve moves. The newest point has no bars after it, so it is a one-sided average. As each new bar arrives, the last stretch of the curve is redrawn with information it did not have before.
- The triangles are not a record. They mark where price crossed the band as it is drawn now. From the code, the script draws them only on the latest bar, and it does not delete triangles drawn on earlier updates. So the ones you see after reloading the chart can differ from the ones you watched appear live.
The script says so itself: in this mode it puts "Repainting Mode Enabled" in a box on the chart. This mode also draws its curve and bands as line objects, so there are no plotted values an alert or a strategy could read. The script has no alert conditions at all.
None of this makes it a bad picture of what price did. It is a fair way to see the shape of past swings. It cannot tell you where the band was at the time.
The non-repainting mode, and what it costs
Turn Repainting Smoothing off and the script switches to what LuxAlgo calls the endpoint method. Each bar's value is a bell-curve-weighted average of that bar and the 499 bars before it, newest weighted most. No future bars are used, so once a bar closes its value does not change. Like any indicator, the current bar still moves until it closes.
The price of that honesty is lag. With bandwidth 8, the average age of the data in each value is about 6 bars. The curve now turns after price turns, the way a moving average does. The bands are plotted, so you can set alerts on them, and the triangles come from a plain cross of the close over the upper or lower band.
If you compare the two modes on the same chart, the difference between the neat curve and the lagging one is what the future bars were contributing.
Where it fails
- In the default mode, nothing on the chart existed at the time. Judging the indicator by how well its past triangles line up with turns is judging it with hindsight built in.
- Lag in the honest mode. About 6 bars at the default bandwidth. A lower bandwidth cuts the lag and adds noise.
- A fixed-width band in the default mode. The band width is one number for the whole window, so it is too wide in quiet stretches and too narrow in volatile ones.
- Long warm-up in the non-repainting mode. From our reading of the code, the bands need roughly 1,000 bars of history before they appear. On a weekly chart of a young symbol you may see nothing.
- A band touch is not a reversal. Price can ride outside a volatility band for a long time in a strong trend.
Does the Nadaraya-Watson Envelope repaint?
Default settings: yes. Each historical point averages bars that came after it, and the curve and triangles are redrawn as new bars arrive. With Repainting Smoothing off: no, not on closed bars. It becomes a lagging, causal moving average with bands, and only the live bar moves. Other authors publish their own non-repainting kernel versions; check any of them the same way, by asking whether a past value uses bars that came after it.
Educational content only. Not investment advice, and not a recommendation to trade. Indicators describe past prices; none of them predicts the next one.
Also explained: Repaint checker, VWAP, Supertrend, RSI, UT Bot Alerts
Get the next teardown by email
One short email when a new teardown or free tool goes live, about twice a month. No signals, no hype. Unsubscribe in one click.
Almost done. Check your inbox and click the confirmation link.
Sent with Kit. Your address is used only for these emails. Privacy