TradingView
LuxAlgo
2021εΉ΄8月24ζ—₯δΈ‹εˆ2點33εˆ†

Nadaraya-Watson Smoothers [LuxAlgo]Β 

Bitcoin / United States DollarCoinbase

描述

β‹…
The following tool smoothes the price data using various methods derived from the Nadaraya-Watson estimator, a simple Kernel regression method. This method makes use of the Gaussian kernel as a weighting function.

Users have the option to use a non-repainting as well as a repainting method, see the USAGE section for more information.

πŸ”Ά USAGE

πŸ”Ή Non Repainting



When Repainting Smoothing is disabled the returned indicator acts similarly to a regular causal moving average. This result could be described as an "endpoint Nadaraya-Watson estimator".

Unlike a regular moving average whose degree of smoothness is commonly determined by the length of its calculation window, the degree of smoothness of the proposed indicator is determined by the bandwidth setting, with a higher value returning smoother results.



In the above chart, a bandwidth value of 50 is used. An increasing value of the smoother is indicative of an uptrend, while a decreasing value is indicative of a downtrend.

πŸ”Ή Repainting

Non-causal smoothing methods have found low support from technical analysts because they tend to repaint. Yet, they can provide powerful insights such as estimating underlying trends in the price as well as seeing how far prices deviate from them. They can also make drawing certain patterns easier and can help see underlying structures in the price more clearly.

Using higher bandwidth values allows for estimating longer-term trends in the price.



Triangular labels highlight points where the direction of the estimator change. This allows for the identification of tops and bottoms in the underlying trend which can be compared to the actual price tops and bottoms.



Note that multiple labels can appear in real time, highlighting real-time changes in the estimator's direction. The most recent label on a series of labels is the first to appear. This can eventually be useful for the real-time predictive application of the estimator. However, it is not a usage we particularly recommend.

πŸ”Ά DETAILS

The Nadaraya-Watson estimator can be described as a series of weighted averages using a specific normalized kernel as a weighting function. For each point of the estimator at time t, the peak of the kernel is located at time t, as such the highest weights are attributed to values neighboring the price located at time t.



A lower bandwidth value would contribute toward a more important weighting of the price at a precise point and would as such less smooth results. In the case where our bandwidth is so small that the resulting kernel is just an impulse, we would get the raw price back.



However, when the bandwidth is sufficiently large, prices would be weighted similarly, thus resulting in a result closer to the price mean.



It can be interesting to note that due to the nature of the estimator and its weighting procedure, real-time results would not deviate drastically for points in the estimator near the center of the calculation window.

πŸ”Ά SETTINGS

  • Bandwidth : controls the bandwidth of the Gaussian kernel, with higher values returning smoother results.
  • Src : Input source of the kernel regression.
  • Repainting Smoothing : Determine if the smoothing method should repaint or not. If disabled the "endpoint Nadaraya-Watson estimator" is returned.

η™ΌεΈƒι€šηŸ₯

β‹…
Minor changes

η™ΌεΈƒι€šηŸ₯

β‹…
Added a disclaimer which displays a small message on the chart. You can hide this from within the settings menu by checking the "Hide Disclaimer" option.

η™ΌεΈƒι€šηŸ₯

β‹…
Minor changes.

η™ΌεΈƒι€šηŸ₯

β‹…
This update allows users of the Nadaraya-Watson Estimator (Smoothers) to now have a collection of smoothing methods and non-repainting functionality if enabled within the settings.

To update to the latest version, please refresh TradingView & then remove/re-add the Nadaraya Watson indicator to your chart.
θ©•θ«–
VonnyFX
β‹…
thomsonraja
β‹…
@VonnyFX, //a simple approximate value can be found for scalping...
//just changing 1 line
//Labels appears when actual SMA 5 period crossover or crossunder SMA 5 period with offset of -2 and because of offset -2 labels repaint

line # 26 changed to ==> w = exp(-(pow(i-j,4)/(h*h*1)))

=====> ======> ======>
aa = sma(close,5)
plot(aa, color = color.lime, offset = -2)

bb = wma(close,4)

var linea = line.new(x1=bar_index-2, y1=aa, x2=bar_index, y2=bb, xloc=xloc.bar_index, style=line.style_solid,extend=extend.none, color=color.yellow)

if time != time[1]
line.set_xy1(id=linea, x=bar_index-2, y=aa)
line.set_xy2(id=linea, x=bar_index, y=bb)

couldnt share my idea because of moderation and always gets deleted....
Food_Plus
β‹…
@thomsonraja, Hi thanks for this beneficial supplement, do you know how to get the colors (green and red) from the Nadaraya-Watson estimator and put them in an SMA?
thomsonraja
β‹…
@Food_Plus, sma greater then previous sma then green orelse red... offset -2
Food_Plus
β‹…
@thomsonraja, Thanks for answering but I wanted to say that I want the same color (bull and bear) of this indicator and put it in an SMA

For example but it doesn't work (put at the end of the code):
Sma = sma(close, 20)
col_Nadaraya = y2 > y1 ? #ff1100 : #39ff14
plot(Sma, color=col_Nadaraya)
thomsonraja
β‹…
@Food_Plus, use y1[1]....
means y1 previous bar value
sma > sma[1] previous value
Food_Plus
β‹…
@thomsonraja, Thank you but I don't see what you mean.. you can explain to me if you have some time of course
thomsonraja
β‹…
@Food_Plus, if sma is greater then previous bar sma then green if lesser then previous bar sma then red....
Food_Plus
β‹…
@thomsonraja, Ak but it's not my request... sorry my English is not very good... I wanted to have exactly the same bull and bear signals (green and red) of this indicator and transmit them in a Sma for example
thomsonraja
β‹…
@Food_Plus, you will have to learn coding bro....
use plotshape with sma and 2period back sma 'crossover and crossunder'.... ull get it...
ζ›΄ε€š