I've been experimenting with Bollinger Bands (BB) based on Heikin Ashi values and can't explain the BB values being returned during backtesting. I've attached a simplified backtest and extensive research notebook that hopefully makes it clearer what I'm seeing. But in essence:
- The Heikin Ashi values are being calculated correctly.
- The Bollinger Band values generated using the IndicatorExtensions.Of extension don't match my own calculations.
The strategy itself is immaterial BUT I do want to understand how the LEAN engine is coming up with these BB values (as some combinations with other indicators look promising).
Any help appreciated! As an aside, in the research notebook, I'm using the object store and Bokeh to visualise the trades generated (see pic below).
Rob Anderson
BTW, bokeh has a nice synchronised wheel zoom option you can use on the chart as well as the left-hand price axis.
Rob Anderson
Oh, and I should have mentioned that the strategy should be entering and exiting above and below the upper and lower bands (equivalent to 1 and 0 percent B). In the notebook, you will see that this is very often not the case as percent B (pb) values seem to be a lot closer to the middle band during backtesting. I really want to know where these values come from (I've probably done something stupid 😂).
Derek Melchin
Hi Rob,
To build the Bollinger Bands using the Heikin Ashi values, we just need to replace
with
Refer to this related thread.
Best,
Derek Melchin
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.
Rob Anderson
Thanks Derek,
I appreciate your helping out. I can now run my backtest and it matches my calculations.
I'm curious though as to what my implementation is doing. From the link you sent me I'm presuming that the BB value is updated twice on every timestep? If so, what value is passed forward?
I know it's odd to ask, but my flawed implementation does produce some interesting results that I'm keen to understand fully (and I haven't yet been able to replicate with my own calculations).
Regards,
Rob Anderson
Varad Kabade
Hi Rob Anderson,
Using shortcut methods to instantiate the indicators will create the indicator and hook them for automatic updates. Therefore the Bollinger band would be updated twice, once with the automatic update and the other with the output of the Heikin Ashi indicator.
Best,
Varad Kabade
Rob Anderson
Hi Varad,
Thank you for the explanation on how my original implementation was generating those values. I can now derive them manually, so fully understand how my hybrid indicator was working 😂. Sometimes odd things lead to interesting results…
Both you and Derek have answered my question and I really appreciate your giving up your time to assist.
Regards, Rob
Rob Anderson
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!