I trying to apply custom indicator on my universes of stocks. I am mostly following examples I found in docs and community. The problem is that my indicator uses close price as inout, but corse object dosan't contain close price property. That is, my custom indicator containts input argument in update method, but I am not sure how I can define input in coarse part. Attached, you can find my backtest (you have to uncomment everzthing, it returned error if I was using cose as is.).
Derek Melchin
Hi Mislav,
The error was occurring because line 77 was trying to access the `Close` property of a CoarseFundamental object. To resolve this, replace `Close` with `Price` or `AdjustedPrice`.
Continuing development with this algorithm, I recommend the following:
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.
Derek Melchin
Hi Mislav,
(3) I meant to warmup inside the constructor of the SelectionData class. See the attached backtest for reference. Note that the `sadf_last` method of the SadfIndicator class has been fixed to return 1 since the `get_sadf` method is not defined yet.
(4) It's recommended. Otherwise, the `sadfs` dictionary will grow without bounds.
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.
Derek Melchin
Hi Mislav,
When uncommented, RegisterIndicator is currently being called during the CoarseSelectionFunction. This is why the error is being thrown. We can only call RegisterIndicator with Symbols that the algorithm has a data subscription for.
The universe is always empty because
self.sadfs[symbol].is_ready()
is always False. Note that in this related thread, the indicator's Update method that returns the readiness only accepts one argument, while the algorithm above accepts two. This is why the indicator is never ready. Furthermore, in the attached backtest, we can see the readiness is only set by the Update method when the algorithm receives data automatically through RegisterIndicator. That is, even calling the method explicitly with a TradeBar object doesn't set the readiness correctly.
A workaround for this is to move
if self.sadfs[symbol].is_ready() and self.sadfs[symbol].sadf < 1:
into an alpha model's Update method instead of in the universe selection method. That way, we can create and register the indicators in the OnSecuritiesChanged method, after the algorithm has the data subscription.
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.
Mislav Sagovac
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!