There are mainly 2 problems
1) when I loop through the rolling window of Heikin Ashi and tried to print the Close, I get 0 in the log
Related code :
for i in self.haWin:
self.Debug("haWin : {}<br>".format(i.Close))
2) when I compare the sma5 based on heikin ashi from the indicator and the number calculated by myself, they seem to be different.
self.Debug("the sma 5 based on Heikin ashi : {}<br>".format(self.sma5.Current.Value))
self.Debug("ha close : {}<br>".format(self.ha.Close))
I took the last 5 close price in the log, close prices are 33.9025, 33.8675, 33.805, 33.80875, 33.82, and the mean at 2020-05-15 15:58:00 is 33.84075(calculated by myself) instead of 33.877(in the log)
Thx
Derek Melchin
Hi Tai Man Chan,
(1) This error can be resolved by adding the `self.ha.CurrentBar` to `self.haWin` instead of creating a new TradeBar.
self.haWin.Add(self.ha.CurrentBar)
(2) This error is because the algorithm updates the SMA with each new candlestick and with each new HeikinAshi bar. See lines 19 and 38 in the backtest code above for reference. We can resolve this by creating a SimpleMovingAverage object in Initialize and only update it with each call to `hdUpdate`.
See the attached backtest which implements the changes listed above.
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.
Tai Man Chan
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!