TradingView
fluxchart
6 nov. 2023 21:47

Bollinger Bands (Nadaraya Smoothed) | Flux Charts 

SPDR S&P 500 ETF TRUSTArca

Description

Ticker: AMEX:SPY, Timeframe: 1m, Indicator settings: default
General Purpose
This script is an upgrade to the classic Bollinger Bands. The idea behind Bollinger bands is the detection of price movements outside of a stock's typical fluctuations. Bollinger Bands use a moving average over period n plus/minus the standard deviation over period n times a multiplier. When price closes above or below either band this can be considered an abnormal movement. This script allows for the classic Bollinger Band interpretation while de-noising or "smoothing" the bands.

Efficacy

Ticker: AMEX:SPY, Timeframe: 1m, Indicator settings: Standard Dev: 2; Level 1 : off; Level 2: off; labels: off
Upper Band Key:
Blue: Bollinger No smoothing
Orange: Bollinger SMA smoothing period of 10
Purple: Bollinger EMA smoothing period of 10
Red: Nadaraya Smoothed Bollinger bandwidth of 6

Here we chose periods so that each would have a similar offset from the original Bollinger's. Notice that the Red Band has a much smoother result while on average having a similar fit to the other smoothing techniques. Increasing the EMA's or SMA's period would result in them being smoother however the offset would increase making them less accurate to the original data.

Ticker: AMEX:SPY , Timeframe: 1m, Indicator settings: Standard Dev: 2; Level 1: off; Level 2: off; labels: off
Upper Band Key:
Blue: Bollinger No smoothing
Orange: Bollinger SMA smoothing period of 20
Purple: Bollinger EMA smoothing period of 20
Red: Nadaraya Smoothed Bollinger bandwidth of 6


This makes the Nadaraya estimator a particularly efficacious technique in this use case as it achieves a superior smoothness to fit ratio.

How to Use
This indicator is not intended to be used on its own. Its use case is to identify outlier movements and periods of consolidation. The Smoothing Factor when lowered results in a more reactive but noisy graph. This setting is also known as the "bandwidth" ; it essentially raises the amplitude of the kernel function causing a greater weighting to recent data similar to lowering the period of a SMA or EMA. The repaint smoothing simply draws on the Bollinger's each chart update. Typically repaint would be used for processing and displaying discrete data however currently it's simply another way to display the Bollinger Bands.

What makes this script unique.
Since Bollinger bands use standard deviation they have excess noise. By noise we mean minute fluctuations which most traders will not find useful in their strategies. The Nadaraya-Watson estimator, as used, is essentially a weighted average akin to an ema. A gaussian kernel is placed at the candlestick of interest. That candlestick's value will have the highest weight. From that point the other candlesticks' values effect on the average will decrease with the slope of the kernel function. This creates a localized mean of the Bollinger Bands allowing for reduced noise with minimal distortion of the original Bollinger data.

Notes de version

Added option to change source used to calculate labels.
Commentaires
JMTradingMaster
Repaint BS
drgentleman1
re--re-re -repaint
fluxchart
@drgentleman1, The default lines and bands are done with the plot function which is 100% real-time-- not repaint. While the “Repaint Smoothing” setting does allow for repaint, the setting is off by default.
wadu
Appreciate your effort and thank you for sharing...Cheers
Tkysl
it repaints signals after 5 bars.
fluxchart
@Tkysl, The Bollinger Bands are not repainted unless the “Repaint Smoothing” setting is turned on. The arrow labels are plotted after a pivot of 4 bars or larger, so they can only be determined after 4 bars have passed. The band break notifications, however, are triggered immediately on close outside the level 1 bands.
russtmg
@fluxchart, i appreciate your efforts but if it repaints or prints 4 bars after it is the same unusefulness
fluxchart
@russtmg, There is now an option for people who wish to have the labels plotted immediately! Change the Pivot Source setting to Close or High/Low rather than Pivot.
patelrajesh1988
@russtmg, it is better than other indicators which give us signals with without confirmation, it calculate n than give us signals which increases more accurate trade
Plus