I am trying to create a custom indicator that records the closing price of a futures contract from the day before so I can compare the current price to yesterday's closing price. I created a SymbolData class for the consolidators. The problem I have is I get the error message “Invalid third argument, should be either a valid consolidator or timedelta object” on line 189 for the custom indicator I created (commented out line 189 so backtest would run), but when I use that exact same consolidator for self.rsi on 198 it works just fine and I get a daily RSI calculation. I have tried using different consolidators and timedeltas and nothing seems to make that error message go away. I am really at a loss on what needs to change in order for my custom indicator to use 1-day-consolidated data.
Any guidance is much appreciated!
Louis Szeto
Hi Critical.Error
For creating a custom indicator, we'll need the PythonIndicator superclass and update the .Value attribute in an overriding Update method. Please check out this sample algorithm for custom indicator usage.
However, we recommend using self.Identity indicator to cache and fetch previous close price:
Best
Louis
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.
Critical.Error
Thank you for replying and helping out!
The self.Identity did not work with futures data. It only ever pulled a value of 0.0. I also couldn't get the custom indicator to pull the closing price from consolidated data. I eventually was able to store the closing price in a variable using that would only update at the end of the day using the OnEndOfDay method. Ended up being much more simple than I was making it.
Critical.Error
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!