I am extremely new to algo coding. Also new relatively new to Python. NOT new to programming (8 years on and off).
This is what I have in Initalize:
self.SetStartDate(2017, 4, 1) # Set Start Date
self.SetEndDate(2020, 4, 1)
self.SetCash(100000) # Set Strategy Cash
self.es = self.AddFuture("ES", Resolution.Minute)
self.es.SetFilter(10, 90)
self.myema = ExponentialMovingAverage(200)
self.RegisterIndicator(self.es.Symbol, self.myema, timedelta(minutes=5))
This is how the docs said to create an EMA and consolidate to 5 mins? Doubt its correct (because of me)
myema.IsReady() always returns false in OnData
when I said "Price" in title: I am confused for backtesting what price would be used to determine a cross of an EMA, Because my understanding is there is no "Last" data logged in previous market data?
Just wondering if someone can start me off. I have absolutely no traction and I've been staring at the docs for 3+ hours
Valen Russo
I guess above anything Im wondering if something different has to be done for backtesting? The concept of the algo looking at live data vs. historical. I saw this rolling window structure. Is that needed for what I'm trying to accomplish?
Rahul Chowdhury
Hi Valen,
For every futures symbol, there is a chain of futures contracts each with different prices and expiry dates. This means we must choose which futures contract we want to trade. The normal convention is to use the front month contract, which is the contract with the nearest expiry. As each front month expires, we will rollover to the next contract in the chain.We can create a "blank" EMA indicator and manually update it with price data from the front month contract. Then we can compare the price of that contract to the value of the EMA before placing an order.
Check out the back test below to see this in action.
Valen Russo
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!