Back

Consolidated + Indicator

I need some help please.

Here is the basic idea:

I'm trying to write a algo that uses ticks , heikin ashi and a rolling window as the data.
For this currently I'm running a consolidator set to 2 minutes, as I can't get the ticks work.
After the consolidator is set I add the heikin ashi indicator and then I  add it to the rolling window.
This will enable me to compare the open value of the current bar with the open / close of the previous bars.

My questions are as follows:

1 - am i adding the indicator correctly, using the consolidated data, and how do i know the data being used is the data that was processed by the indicator?

2 - how do i change the consolidator to run on ticks instead of time?

2 - how can i add a candle stick graph / plot of this data (the consolidated, heikin ashi processed data) to the output?

Here is my current code that should be doing this.

ha = HeikinAshi

def Initialize(self):
self.window = RollingWindow[QuoteBar](2)

def OnData(self,slice):
consolidator = QuoteBarConsolidator(timedelta(minutes=2))
consolidator.DataConsolidated += self.OnDataConsolidated
self.SubscriptionManager.AddConsolidator(contract.Symbol, consolidator)
self.RegisterIndicator(contract.Symbol, self.HA, consolidator)

def OnDataConsolidated(self, sender, data):
if not (self.HA.IsReady): return
self.window.Add(data)

if(currBar.Close > pastBar.Close + 1):
#do some stuff
Update Backtest







Please share an algorithm (use the attach backtest button below) that shows the issue you are experiencing.
This procedure helps us, the community, to answer your questions quickly and effectively.

From the code snippet, I can see that you are not initializing the consolidator properly. In the docs, we can read:
"You set up the consolidator and bind to this event handler once from inside your Initialize() method."

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.


Thank you for the comment. I re-evaluated the script and strated from stratch, in order to put it together step by  step.

How do you add a particular future symbol? I want to trade ES and NQ specifically.
 

0


Thank you! The code in mainV1.pyp is almost perfect.
You just need to create a dictionary of symbols to save a HeikiAshi for each contract:

# In Initialize
self.HA = dict()

# In OnData
self.HA[contract.Symbol] = HeikinAshi()
self.RegisterIndicator(contract.Symbol, self.HA[contract.Symbol], consolidator)


 

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