Calendar Icon - Evolve Algo
February 11, 2024
Clock Icon - Evolve Algo
6
 min read

Nadaraya Watson Envelope

How to use, trade and calculate the Nadaraya Watson Envelope

Nadaraya Watson Envelope

Nadaraya Watson Envelope

Notes:

These indicators and concepts are specifically designed for TradingView.com

Overview

The Nadaraya-Watson Envelope is a technical indicator that is used to estimate the upper and lower bounds of a trading range. It is named after two statisticians, K. G. Nadaraya and G. Watson, who developed the algorithm for non-parametric regression analysis.

How to Trade

We use the envelope as a mean reversion signal. When the price of the security is above the upper envelope, it may be overbought, and when the price is below the lower envelope, it may be oversold. A buy signal is generated when the price crosses below the lower envelope, and a sell signal is generated when the price crosses above the upper envelope. This is because the upper and lower bands are primarily based on the highest and lowest price extremes.

Nadaraya Watson Envelope

How to Calculate

This is one of the most complex formulas to comprehend so an overview of calculation will be provided, but here is the process of calculation:

  1. Choose a kernel function: The first step is to choose a kernel function, which is a mathematical function that assigns weights to the data points. The weights determine how much influence each data point has on the regression line. A commonly used kernel function is the Gaussian kernel, which assigns higher weights to data points that are closer to the regression point.
  2. Choose a bandwidth parameter: The next step is to choose a bandwidth parameter, which determines the width of the regression window and controls the degree of smoothing. A larger bandwidth results in a smoother regression line, while a smaller bandwidth results in a more volatile line. The bandwidth parameter can be chosen based on the volatility of the security or through cross-validation techniques.
  3. Calculate the weighted average of the data points: For each point in the price series, calculate the weighted average of the neighboring data points using the kernel function and the bandwidth parameter. The regression line represents the conditional expectation of the price given the values of the neighboring data points.
  4. Calculate the upper and lower envelopes: The upper and lower envelopes of the Nadaraya-Watson Envelope are calculated by adding and subtracting a certain number of standard deviations from the regression line. The number of standard deviations can be chosen based on the volatility of the security or through backtesting techniques.

Now for the formula:

Regression line:

h(t) = Σw(i,t)p(i) / Σw(i,t)

where:h(t) = the regression line at time tw(i,t) = the weight assigned to data point i at time t based on the kernel function and bandwidth parameter p(i) = the price data point at time i

Upper envelope:

U(t) = h(t) + k*σ

where:U(t) = the upper envelope at time th(t) = the regression line at time tk = the number of standard deviations from the regression line to the upper envelope (can be chosen based on volatility or backtesting)σ = the standard deviation of the price data over a certain time period (can be chosen based on volatility or backtesting)

Lower envelope:

L(t) = h(t) - k*σ

where:L(t) = the lower envelope at time th(t) = the regression line at time tk = the number of standard deviations from the regression line to the lower envelope (can be chosen based on volatility or backtesting)σ = the standard deviation of the price data over a certain time period (can be chosen based on volatility or backtesting)

The kernel regression method uses a kernel function to assign weights to the data points based on their distance from the regression point. The bandwidth parameter controls the degree of smoothing of the regression line, with a larger bandwidth resulting in a smoother line and a smaller bandwidth resulting in a more volatile line.

Latest articles

Browse all