How can I pass heikin-ashi prices to indicators like EMA and SMA when using consolidators?
#Consolidate minute data into X minute blocks
Consolidated = TradeBarConsolidator(timedelta(minutes=self.Period))
Consolidated.DataConsolidated += self.onDataConsolidated
interval = Consolidated
self.SubscriptionManager.AddConsolidator(self.symbol, interval)
# technicals
self.HA = HeikinAshi()
self.ema10 = ExponentialMovingAverage(10)
self.ema50 = ExponentialMovingAverage(50)
self.sma25 = SimpleMovingAverage(25)
self.RegisterIndicator(self.symbol, self.ema10, Consolidated)
self.RegisterIndicator(self.symbol, self.sma25, Consolidated)
self.RegisterIndicator(self.symbol, self.ema50, Consolidated)
self.RegisterIndicator(self.symbol, self.HA, Consolidated)
self.window = RollingWindow[float](2)
self.SetWarmup(50)
Derek Melchin
Hi Rajats179,
We can accomplish this with IndicatorExtensions.
self.HA = HeikinAshi() self.sma_of_ha = IndicatorExtensions.Of(SimpleMovingAverage(5), self.HA)
See the attached backtest for reference.
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.
Vladimir
Derek Melchin,
As far as I remember Heikin Ashi Chart is a specific way of ploting data bars, where
HA_Close[-1] = (Open[-1] + High[-1] + Low[-1] + Close[-1]) / 4
HA_Open[0] = Open[0]
HA_Open[-1] = (HA_Open[-2] + HA_Close[-2]) / 2
HA_High[-1] = max(High[-1], HA_Open[-1], HA_Close[-1])
HA_Low[-1] = min(Low[-1], HA_Open[-1], HA_Close[-1])
Can we get HA_Open, HA_High, HA_Low, HA_Close from the function HeikinAshi()?
What is the default output of HeikinAshi()?
Derek Melchin
Hi Vladimir,
To get the HA open, high, low, and close values, we can use:
self.HA.Open.Current.Value self.HA.High.Current.Value self.HA.Low.Current.Value self.HA.Close.Current.Value
The default value (`self.HA.Current.Value`) is equal to the HA close (`self.HA.Close.Current.Value`). See the attached backtest for reference.
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.
Vladimir
Derek Melchin,
Thank you so much for your explanation.
I unsuccessfully tried to create a custom plot with Heikin Ashi Candlestick chart.
Can you help with that?
Derek Melchin
Hi Vladimir,
It's not currently possible to create custom candlestick plots like this. For now, we recommend saving the candles in the ObjectStore and plotting them in the Research environment.
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.
Rajats179
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!