Generalized Bollinger Bands %B And Bandwidth (Tartigradia)Bollinger Band is simply a representation of the rolling average of price and its standard deviation around the average (called the "basis").
This indicator generalizes the Bollinger Band by implementing many different equations to calculate the Bollinger Bands beyond the standard deviation and sma, and then plot the %B (where the current price falls inside the Bollinger Band), Bandwidth (size of the Bollinger Band) as well as the Bollinger Band itself and a reproduction of the OHLC price candles in a separate pane.
Whereas other Bollinger Bands indicators often just change the basis but not the stdev calculation, the correct way to change the basis is to also change it inside the stdev calculation.
Advanced features such as temporal discounting (ie, newer bars can have more weights), median absolute deviation and multiple sigma bands (eg, 3-sigma) are available.
Up to 3 different Bollinger Bands can be displayed, and the background can be highlighted when price is overbought/oversold (beyond the Bollinger Band of choice). Tip: BB3, which is the bollinger band with standard deviation of 3, which represents 99% of observed values in the lookback period, is a good choice to highlight overbought/oversold conditions.
Three "Sentiment Bars" are provided to see at a glance the sentiments on the price action relative to the Bollinger Bands as reflected by the %B value.
Usage:
Use the %B as a measure of sentiment: bullish if > 0.5, bearish if < 0.5. You can use the Sentiment Bars at the bottom for a quick reference: aqua if bullish, red if bearish, gray if undefined (too close to the middle line).
Use the bandwidth as a measure of volatility: higher is more volatile, lower is less.
When overbought, it can be a good time to sell/short. Use a higher Bollinger Band Multiplier such as 3 or more to reduce false positives.
When oversold, it can be a good time to buy/long. Use a higher Bollinger Band Multiplier such as 3 or more to reduce false positives.
Consider setting a much tighter lookback period of 4 as recommended in backtested works (en.wikipedia.org), use zlma instead of sma, and finally set a higher timeframe for the Bollinger Bands than the one you are currently studying. Then, the Bollinger Bands can help in detecting overbought and oversold regions (price going "out of bands").
Note that I tried to automate the setting of a higher timeframe, but for some reason the output is different when I manually do it using request.security() than when it's in indicator(timeframe=""). If someone has any suggestion as to why it happens, please let me know! (You can try it for yourself by uncommenting the auto_timeframe parameter line).
Bollingerbandspercentb
Bollinger Bands Width and Bollinger Bands %BThis script shows both the Bollinger Band Width(BBW) and %B on the same indicator window.
Both the BBW and %B are introduced by John Bollinger(creator of Bollinger Bands) in 2010.
Default Parameter values: Length = 20, Source = Close, Mult = 2
Bollinger Bands Width (BBW): Color = (Default: Green )
- I consider stocks with "BBW >= 4" are at a volatile state and ready for price contraction, but this depends on the parameter values of your choice.
Bollinger Bands %B (%B): Color = (Default: Blue )
1. %B Above 10 = Price is Above the Upper Band
2. %B Equal to 10 = Price is at the Upper Band
3. %B Above 5 = Price is Above the Middle Line
4. %B Below 5 = Price is Below the Middle Line
5. %B Equal to 0 = Price is at the Lower Band
6. %B Below 0 = Price is Below the Lower Band
+ %UMAIf you are familiar with the %B for use with Bollinger Bands, then you will understand this indicator immediately.
Designed for use with my +UMA moving average, this works in exactly the same way, with a few differences.
First off, as you can choose on which type of moving average the calculations are made, so too you will want to match this up with the one you are using. That of course goes for the standard deviation as well (just like you would with Bollinger Bands and %B). Here, because the +UMA uses highs and lows to create a sort of moving average channel, and then also to create the bands, I've opted to set the inner part of the bands as the extreme edge that the %UMA equates with the upper and lower lines.
I've added a moving average, donchian channels, and auto-plotted divergences as well, if you like. Typical color related stuff that I do. Alerts for everything.
Hope you like it!
The above image is comparing two of the same indicator, but based on different moving averages, and how it might plot divergences differently between the two.
Risk Reduction Ultimate TemplateThis is a template not actually meant for trading. I picked two random oscillators. This is a template meant to turn into a live trading strategy, however.
It's literally just a specialized take profit/stop loss system. It is to ensure your bot doesn't make any bad moves that you wouldn't have manually. The code should be pretty well annotated. Putting this into my scripts has made them much better. I will work on a Multiple Trigger template next.
+ BB %B: MA selection, bar coloring, multi-timeframe, and alerts+ %B is, at its simplest, the classic Bollinger Bands %B indicator with a few added bells and whistles.
However, the right combination of bells and whistles will often improve and make a more adaptable indicator.
Classically, Bollinger Bands %B is an indicator that measures volatility, and the momentum and strength of a trend, and/or price movements.
It shows "overbought" and "oversold" spots on a chart, and is also useful for identifying divergences between price and trend (similar to RSI).
With + %B I've added the options to select one or two moving averages, candle coloring, and a host of others.
Let's start with the moving averages:
There are options for two: one faster and one slower. Or combine them how you will, or omit one or both of them entirely.
Here you will find options for SMA, EMA (as well as double and triple), Hull MA, Jurik MA, Least Squares MA, Triangular MA, Volatility Adjusted MA, and Weighted MA.
A moving average essentially helps to define trend by smoothing the noise of movements of the underlying asset, or, in this case, the output of the indicator.
All of these MAs available track this in a different way, and it's up to the trader to figure out which makes most sense to him/her.
MA's, in my opinion, improve the basic %B by providing a clearer picture of what the indicator is actually "seeing", and may be useful for providing entries and exits.
Next up is candle coloring:
I've added the option for this indicator to color candles on the chart based on where the %B is in relation to its upper and lower bounds, and median line.
If the %B is above the median but below the upper bound, candles will be green (showing bullish market structure). If %B is below the median but above the lower bound, candles will be red (denoting bearish market structure).
Overbought and oversold candles will also be colored on the chart, so that a quick glance will tell you whether price action is bullish/bearish or "oversold"/"overbought".
I've also added functionality that enables candles to be colored based on if the %B has crossed up or crossed down the primary moving average.
One example as a way to potentially use these features is if the candles are showing oversold coloration followed by the %B crossing up your moving average coloration. You might consider a long there (or exit a short position if you are short).
And the last couple of tweaks:
You may set the timeframe to whatever you wish, so maybe you're trading on the hourly, but you want to know where the %B is on the 4h chart. You can do that.
The background fill for the indicator is split into bullish and bearish halves. Obviously you may turn the background off, or make it all one color as well.
I've also added alerts, so you may set alerts for "overbought" and "oversold" conditions.
You may also set alerts for %B crossing over or under the primary moving average, or for crossing the median line.
All of these things may be turned on and off. You can pretty much customize this to your heart's delight. I see no reason why anyone would use the standard %B after playing with this.
I am no coder. I had this idea in my head, though, and I made it happen through referencing another indicator I was familiar with, and watching tutorials on YouTube.
Credits:
Firstly, thanks to www.tradingview.com for his brilliant, free tutorials on YouTube.
Secondly, thanks to www.tradingview.com for his beautiful SSL Hybrid indicator (and his clean code) from which I obtained the MAs.
Please enjoy this indicator, and I hope that it serves you well. :)