I’ve searched this up quite a bit and don’t see any answers for this issue. When loading in futures contracts, you have to put a slice object into the OnData section. Therefore, you can’t create indicators like you can for equities. You’d have to put it into OnData. Does anyone have an example of a simple indicator on a futures contract? Like how to pull the most recent futures S&P contract and get RSI or SMA indicators on it?
Nico Xenox
Hey David Eldringhoff,
you could take a look at this example:
David Eldringhoff
Hey thanks for that. I'm looking at this code. This issue with trading futures looks really challenging. I would like to calculate the slope of an EMA on a 5 minute bar and use a MACD histogram on a 5 minute bar. With the futures contracts changing and not being able to do this stuff up in initialize it seems daunting. I cant figure out how to use a bar handler function without being able to set it up in initialize like I would normally for other securities.
Nico Xenox
Hey David Eldringhoff,
you could start the following way:
If you dont want to work with the symbol data class you could take a look at this post by Derek. This simply checks if it has a contract and if it doesnt it selects a new one.
Here's another one that has indicators included: link
Best,
Nico
David Eldringhoff
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!