Back

Plotting a Bollinger Band

I hava difficulties plotting a correct upper and lower band for the Bollinger Band indicator. The result from my code does show the same shape of the graph but does not match the upper and lower bands.

Bellow is the code, which should be plotting the Bollinger Bands

 self.bband = self.BB("EURUSD", 20, 2, MovingAverageType.Simple)  #, Resolution.Minute);
       
        self.RegisterIndicator("EURUSD", self.bband, Consolidator)
       
        self.SetWarmUp(100)

 self.Plot("BB", "UpperBand", self.bband.UpperBand.Current.Value)
        self.Plot("BB", "MiddleBand", self.bband.MiddleBand.Current.Value)
        self.Plot("BB", "LowerBand", self.bband.LowerBand.Current.Value)

Any idea where the calculations might be going wrong?

 

Update Backtest







0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Ruslan,

I’m unsure of the problem at hand, but based on what I see, I assume the problem is registering an indicator that uses 5-minutes consolidated bars. If we are consolidating data, we need to create a custom BollingerBands instead of creating it using self.BB when registering our indicator because if we update an indicator created with self., then our indicator would be updated twice the desired number of times. I’ve shown how to do this in the attached backtest. 

Best,
Shile Wen

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed