Free: indicator teardowns, a repaint checker and open-source scripts. No buy/sell signals, ever.

Taught to TradeSystems over signals.

Explainers / Nadaraya-Watson Envelope

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":

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:

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

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, Squeeze Momentum, What is repainting on TradingView?, Is TradingView backtesting accurate?, Chandelier Exit, WaveTrend Oscillator, QQE MOD, Pivot highs and lows, Hull Suite, Range Filter, Twin Range Filter, HalfTrend, ZigZag++, SSL Hybrid, CM MacD Ultimate MTF, Volume Profile / Fixed Range, ADX and DI, Support Resistance Channels, Market Structure Break & Order Block, Order Block Finder, Pivot Point SuperTrend, Trendlines with Breaks [LuxAlgo], Divergence for Many Indicators, TradingView script selling terms, Support and Resistance Levels with Break, Liquidity Swings [LuxAlgo], Pine Script errors, Breakout Probability (Expo), Did ChatGPT or Claude write your Pine Sc, Lorentzian Classification, SuperTrend AI (Clustering), Machine Learning Adaptive SuperTrend, Dynamic Swing Anchored VWAP, Support and Resistance Power Channel by , Support and Resistance (High Volume Boxe, Trendline Breakouts With Targets by Char, Breakout Finder by LonesomeTheBlue

Next steps

  • Get a script fixed. Compiles but behaves differently live, or changes after a reload? In a Pine Script Audit, an AI model reads every line and writes a report on what to fix for $49, or also fixes those problems for $149. It cannot prove a script is safe.
  • Check your own script. Paste its source into the free repaint checker. It runs in your browser and flags known patterns.
Before you trust its backtest: the Integrity Checklist, $19 one-offBack to Taught to Trade

No TradingView account yet? This affiliate link gives you a $15 coupon toward a paid plan, and we earn a commission if you buy one. The free plan is enough to follow this page.