OPEN-SOURCE SCRIPT

Bollinger Bands + Keltner Channel Refurbished

已更新
█ Goals

This is an indicator that brings together Bollinger Bands and Keltner's Channels in one thing.
Both are very similar, so I decided to make a merge of the best features I found out there.
Here there is the possibility of choosing one of these two as needed.

In addition, I added the following resources:
1. Pre-Defined intermediate bands with Fibonacci values;
2. Detachment of the bands in which the price was present;
3. Choice of Moving Average:
"Simple", "Exponential", "Regularized Exponential", "Hull", "Arnaud Legoux", "Weighted Moving Average", "Least Squares Moving Average (Linear Regression)", "Volume Weighted Moving Average", "Smoothed Moving Average", "Median", "VWAP");
4. Statistics: bars count within the bands.


█ Concepts

Keltner Channels vs. Bollinger Bands

"These two indicators are quite similar.
Keltner Channels use ATR to calculate the upper and lower bands while Bollinger Bands use standard deviation instead.
The interpretation of the indicators is similar, although since the calculations are different the two indicators may provide slightly different information or trade signals."
(Investopedia)

Bollinger Bands (BB)

"Bollinger Bands (BB) are a widely popular technical analysis instrument created by John Bollinger in the early 1980’s.
Bollinger Bands consist of a band of three lines which are plotted in relation to security prices.
The line in the middle is usually a Simple Moving Average (SMA) set to a period of 20 days (the type of trend line and period can be changed by the trader; however a 20 day moving average is by far the most popular).
The SMA then serves as a base for the Upper and Lower Bands which are used as a way to measure volatility by observing the relationship between the Bands and price.
Typically the Upper and Lower Bands are set to two standard deviations away from the SMA (The Middle Line); however the number of standard deviations can also be adjusted by the trader."
(TradingView)

Keltner Channels (KC)

"The Keltner Channels (KC) indicator is a banded indicator similar to Bollinger Bands and Moving Average Envelopes.
They consist of an Upper Envelope above a Middle Line as well as a Lower Envelope below the Middle Line.
The Middle Line is a moving average of price over a user-defined time period.
Either a simple moving average or an exponential moving average are typically used. The Upper and Lower Envelopes (user defined) are set a range away from the Middle Line.
This can be a multiple of the daily high/low range, or more commonly a multiple of the Average True Range."
(TradingView)


█ Examples

Bollinger Bands with 200 REMA:
快照

Keltner Channel with 200 REMA:
快照

Bollinger Bands with 55 ALMA:
快照

Keltner Channel with 55 ALMA:
快照

Bollinger Bands with 55 Least Squares Moving Average:
快照


█ Thanks

- TradingView (BB, KC, ATR, MA's)
- everget (Regularized Exponential Moving Average)
- TimeFliesBuy ("Triple Bollinger Bands")
- Rashad ("Fibonacci Bollinger Bands")
- Dicargo_Beam ("Is the Bollinger Bands assumption wrong?")
版本注释
Labels was too long
版本注释
Following is correction of the error reported by the user @huratub.
The counting of the total number of bars within the Bollinger Bands was wrong, failing to count the first bar.
Below is an example of the bug and then the result after the correction.

Bug:
快照

After correction:
快照

Thanks
版本注释
1. Standard Deviation for Bollinger Bands now can be calculated based on price (default), or based on central moving average.
In some cases this reduce noise.

2. Added new moving averages (thanks for MightyZinger and TV):

Rolling VWAP (thanks to TV)
Symmetrically Weighted Moving Average
Relative Moving Average
Triangular Simple Moving Average
Triangular Exponential Moving Average
Volatility Adjusted Moving Average
Zero Lag Simple Moving Average
Zero Lag Exponential Moving Average
Variable Index Dynamic Average
Fractal Adaptive Moving Average
Kaufman Adaptive Moving Average (KAMA)
Coefficient of Variation Weighted Moving Average (CVWMA)
Jurik Moving Average
Sine-Weighted Moving Average
Geometric Mean Moving Average
Welles Wilder Moving Average
Geometric Moving Average
版本注释
Error Handling for VWAP and Rolling VWAP
版本注释
- Added new moving averages via libraries (credits: CrackingCryptocurrency).
- Added ALMA (Arnaud Legoux Moving Averag) parameterization.
版本注释
Added End Point Moving Average.
Thanks to Franklin Moormann (cheatcountry).
版本注释
- Code optimized to use a unique library of moving averages.
- New moving averages available (for more information access the library at:
Moving Averages Proxy

- Added some unique parameters of certain averages.

- Updated list of moving averages:
AARMA = 'Adaptive Autonomous Recursive Moving Average'
ADEMA = '* Alpha-Decreasing Exponential Moving Average'
AHMA = 'Ahrens Moving Average'
ALMA = 'Arnaud Legoux Moving Average'
ALSMA = 'Adaptive Least Squares'
AUTOL = 'Auto-Line'
CMA = 'Corrective Moving average'
CORMA = 'Correlation Moving Average Price'
COVWEMA = 'Coefficient of Variation Weighted Exponential Moving Average'
COVWMA = 'Coefficient of Variation Weighted Moving Average'
DEMA = 'Double Exponential Moving Average'
DONCHIAN = 'Donchian Middle Channel'
EDMA = 'Exponentially Deviating Moving Average'
EDSMA = 'Ehlers Dynamic Smoothed Moving Average'
EFRAMA = '* Ehlrs Modified Fractal Adaptive Moving Average'
EHMA = 'Exponential Hull Moving Average'
EMA = 'Exponential Moving Average'
EPMA = 'End Point Moving Average'
ETMA = 'Exponential Triangular Moving Average'
EVWMA = 'Elastic Volume Weighted Moving Average'
FAME = 'Following Adaptive Moving Average'
FIBOWMA = 'Fibonacci Weighted Moving Average'
FISHLSMA = 'Fisher Least Squares Moving Average'
FRAMA = 'Fractal Adaptive Moving Average'
GMA = 'Geometric Moving Average'
HKAMA = 'Hilbert based Kaufman\'s Adaptive Moving Average'
HMA = 'Hull Moving Average'
JURIK = 'Jurik Moving Average'
KAMA = 'Kaufman\'s Adaptive Moving Average'
LC_LSMA = '1LC-LSMA (1 line code lsma with 3 functions)'
LEOMA = 'Leo Moving Average'
LINWMA = 'Linear Weighted Moving Average'
LSMA = 'Least Squares Moving Average'
MAMA = 'MESA Adaptive Moving Average'
MCMA = 'McNicholl Moving Average'
MEDIAN = 'Median'
REGMA = 'Regularized Exponential Moving Average'
REMA = 'Range EMA'
REPMA = 'Repulsion Moving Average'
RMA = 'Relative Moving Average'
RSIMA = 'RSI Moving average'
RVWAP = '* Rolling VWAP'
SMA = 'Simple Moving Average'
SMMA = 'Smoothed Moving Average'
SRWMA = 'Square Root Weighted Moving Average'
SW_MA = 'Sine-Weighted Moving Average'
SWMA = '*Symmetrically Weighted Moving Average'
THEME = 'Triple Exponential Moving Average'
THMA = 'Triple Hull Moving Average'
UMBRELLA = 'Triangular Exponential Moving Average'
TRSMA = 'Triangular Simple Moving Average'
TT3 = 'Tillson T3'
VAMA = 'Volatility Adjusted Moving Average'
VIDYA = 'Variable Index Dynamic Average'
VWAP = '*VWAP'
VWMA = 'Volume-weighted Moving Average'
WMA = 'Weighted Moving Average'
WWMA = 'Welles Wilder Moving Average'
XEMA = 'Optimized Exponential Moving Average'
ZEMA = 'Zero-Lag Exponential Moving Average'
ZSMA = 'Zero-Lag Simple Moving Average'
版本注释
- New theme and colors.
- Option to quickly change the level of transparency of the background color of the bands.
- Option to change baseline color according to price position.

* I would like to add other color options, but due to the limited amount of inputs, it was left with shades of green and red.
If you prefer other colors I suggest making a copy of the script and manually changing the variables in the source code.
版本注释
- Some internal lines were removed to make the script faster. In addition, the excess of lines leaves the graph polluted.
- Possibility to customize colors, background and lines.
版本注释
- Removed unused parameters.
- For a reason I don't know, the Style tab doesn't save the parameters.
So now, to make it easier to hide certain bands, just enter zero.
版本注释
🧾Summary:

1. Source code optimization to improve processing speed.
2. Default colors have been modified for better viewing.
3. Added the possibility to customize the horizontal position of the labels.
4. Added new indicator (band style): Parallel Channels.
5. Added new moving average (MA): 'Donchian Middle Channel High-Low Version'

🔎Details:

1. Parallel Channels:

The channels are obtained like this:

a) Capture the maximums and minimums
b) Calculate the respective averages
c) The final average is calculated, taking the amplitude between the top average and the bottom average, dividing by the parameterized divisor, and finally multiplying by the multiplier.

2. Donchian Channel

In the specific case of Donchian, it was decided to perform the calculation a little differently.
The average (base) is obtained in two ways.

In the standard way, the closing high is added to the closing low, and the result is divided by 2.
This is done using the 'Donchian Middle Channel' option.

The other way, which has just been added, is via the 'Donchian Middle Channel High-Low Version' option.
Here, the highs and lows are added (it's not the closing, it's the tip of the wick) and the result is divided by 2.

The two variants of Donchian Channel presented here differ from traditional Donchian.
In traditional Donchian, the chart is limited to just showing the base, plus an upper band (delimited by the high of the last N periods), plus the lower band (delimited by the low of the last N periods).

The improvement shown here in this indicator is that the Donchian is not limited to just an upper and lower band.
There are 3 possibilities: (1) standard deviation of Bollinger Bands, (2) Keltner channels, and the (3) newly added parallel channels.

What defines the location of the bands are the parameters in relation to the base, and not just the highs and lows.
版本注释
❌ In the 1 second graph, the labels were appearing duplicated, due to a synchronization problem:
快照

✅ Problem fixed:
快照
版本注释
Added VWAP standard deviation bands option.
Although these standard deviations are taken from the VWAP, the bands can be used with other averages as well.

快照

This allows using this indicator in the conventional way that the VWAP is used, but with the benefits included here.
Below is a comparison between the standard VWAP and the new indicator:
快照
ATRAverage True Range (ATR)bollinger_bandsBollinger Bands (BB)bollingersbandkeltnerchannelKeltner Channels (KC)keltnerchannelsbandsmoving_averagemoving_averages

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?


To contribute to my work:
⚡Bitcoin Lightning: forwardocean64@walletofsatoshi.com
🟠Bitcoin: bc1qv0j28wjsg6l8fdkphkmgfz4f55xpph893q0pdh
🔵PayPal: paypal.com/donate/?hosted_button_id=D9KRKY5HMSL9S
更多:

免责声明