Hello,

I am trying to create an extended version of the Bollinger Bands indicator that would include the Band Width and %B as described by John Bollinger in its book ‘Bollinger on Bollinger Bands’ (I have also created a GitHub ticket).

I started by copying the code from the Bollinger Bands indicator on GitHub and tried to extend it from there. I ran into the following issues and would appreciate some guidance:

  1. In the custom indicator file (BBextended.cs), I have tried several things but I could not manage to get the current close price that I need to calculate the %B. I found a way around it which is to use a SMA indicator with a period of 1 (line 10), but I would like to understand how to do that the proper way. Also, to cross check the result, I have plotted the %B calculated from in the indicator vs. a %B calculated in the OnData method and if you look at the %B graph, you will notice that there are some slight differences between the two calculation.
  2. I wanted to apply a Bollinger Band indicator to the %B value of my custom indicator but I am getting an error. If you uncomment line 48 of ‘SymbolData.cs’ you will see “Cannot implicitly convert type 'QuantConnect.BollingerBandsExtended' to 'QuantConnect.Indicators.BollingerBands'”.
  3. The BandWidth indicator (line 85 in BBextended.cs) should be multiply by 100 for a cleaner reading. I tried several variations of the code below but I am getting an error. That’s just a minor cosmetic change but it would be good for my understanding to know how to do that.
BandWidth = (UpperBand.Minus(LowerBand).Over(MiddleBand).Times(100m, name + "_BandWidth");

Many thanks!

Author