I keep getting an error:
RSI is greater then 53
87 | 23:27:57: Runtime Error: TypeError : unindexable object at OnData in main.py:line 41
TypeError : unindexable object (Open Stacktrace)
I am not sure why this error is coming up. I tried a search on Google, but just can't figure this one out.
Here is the snippet of code that is causing the issues:
### Long Entry
if self.rsi.Current.Value < 10 and self.Portfolio["GBPUSD"].Invested <= 0:
if data.QuoteBars["GBPUSD"].Close >= self.sma.Current.Value:
self.MarketOrder("GBPUSD", 1000) ###The error happens on this line per backtest error###
self.Debug("Market order was placed")
if self.rsi.Current.Value > 53:
self.Debug("RSI is greater then 53")
self.Liquidate()
Alexandre Catarino
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.
I guess the issue comes from data.QuoteBars["GBPUSD"], please use data["GBPUSD"].
Also, self.Portfolio[Symbol].Invested is a boolean, so you don't need to compare it to 0.
### Long Entry if self.rsi.Current.Value < 10 and not self.Portfolio["GBPUSD"].Invested: if data["GBPUSD"].Close >= self.sma.Current.Value: ticket = self.MarketOrder("GBPUSD", 1000) self.Debug(f"Market order was placed: {ticket}") if self.rsi.Current.Value > 53: self.Debug("RSI is greater then 53") self.Liquidate()
StryderDk
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!