ClassicScott

+ 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 https://www.tradingview.com/u/ZenAndTheA... for his brilliant, free tutorials on YouTube.
Secondly, thanks to https://www.tradingview.com/u/Mihkel00/ 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. :)
Release Notes:
Added bar coloring for Moving Average crosses. Typically MA crosses lag a lot. In this instance the idea is to smooth the motion of the %B indicator by using the Primary Moving Average to smooth the %B, and the Secondary Moving Average as a signal for trade entries and/or exits.

In the screenshot is an example of this. The Primary MA is a 4 period SMA, and the Secondary MA is a 20 period SMA. One can see how the MA smooths the %B's often choppy movement.

Also, if you're already using the indicator you might notice that the default source setting is as 'hl2'. This is because hl2 produces a smoother line versus simply using the close of the period.
Release Notes: Added bar coloring for Moving Average crosses.

Typically MA crosses lag a lot, and using them for trade entries or exits is less than ideal. In this instance the idea is to smooth the action of the %B indicator by using the Primary Moving Average to smooth the %B (set it to a very short length), and then use the Secondary Moving Average as your signal for trade entries and/or exits.

If you do this I would turn off the actual %B and %B MA crossing candle colors, and just use the MA crossing candle colors, otherwise it’s just a messy chart and a messy indicator.

Also, if you're already using the indicator you might notice that the default source setting is as 'hl2'. This is because hl2 produces a smoother line versus simply using the close of the period
Release Notes: Added Modular Filter as a moving average type.
Changed default source to hlc3

Furthermore, as I had a couple of issues with updates of this in the past, I'm going to reiterate the additions, and why I made them, prior to this iteration.

Added bar coloring for Moving Average crosses.

Typically MA crosses lag a lot, and using them for trade entries or exits is less than ideal. In this instance the idea is to smooth the action of the %B indicator by using the Primary Moving Average to smooth the %B (set it to a very short length), and then use the Secondary Moving Average as your signal for trade entries and/or exits.

If you do this I would turn off the actual %B and %B MA crossing candle colors, and just use the MA crossing candle colors, otherwise it’s just a messy chart and a messy indicator.

Also, the default source setting is set as 'hlc3'. This is because hlc3 produces a smoother line versus simply using the close of the period, and that is my preferred way of measuring price movement with an indicator.
Release Notes: Just added another moving average: the RexDog Average created by one of the best traders out there in my opinion. You can find his profile here:
https://www.tradingview.com/u/xkavalis/
and I would highly recommend joining his Discord and subscribing to his YouTube channel. Not trying to shill the guy, but you can find out how the MA works by looking at his script for it. It's quite simple, though probably better as a chart overlay than as an MA for the %BB, imo.

Also, changed some candle colors, as I'm wanting to keep things aesthetically consistent across my indicators and trading panel. I'll be updating those too with the new RDA.
Release Notes: Updates include cleaning up the candle coloring code a bunch, and adding a neutral candle color and %B color to the indicator that helps to identify areas of indecision, consolidation, or reversals in the market (same thing I've added to my other indicators). Basically, if the %B is bullish relative to the primary MA, but bearish relative to the median it will be grey (as will candles if you have candle colors on), and if the %B is bearish relative to the primary MA, but above the median it will also be grey.
Added an input for turning candle colors on or off completely.
Changed linewidth to 2.
Release Notes: Made an adjustment to primary moving average color that I forgot in the last update.
Added Jurik phase as an input.
Release Notes: added Arnaud Legoux Moving Average (ALMA) to moving averages lists
added plot shapes for %B MA crosses
added background colors for MA MA2 crosses
Release Notes: changed some verbiage that I missed in the MA+MA Cross BG.... I'm tired....
Release Notes: fresh update!
added bollinger bands (how meta, but it works quite well as you can see in the picture)
changed background color to reflect %B crossing the mid
two sets of plot shapes for %B and MA crosses, or MA and MA crosses (if you're using the first MA as a smoothed %B)
cleaned up the code a bit, and cleaned up the inputs tab
Release Notes: just fixing something with oversold candle colors and the %B that I changed in a previous update that was not a good idea, so, not an update to anything but a fix to a problem I created myself :D
Skript med en öppen källkod

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Vill du använda det här skriptet i ett diagram?