I have an algorithm that needs the 21 day Exponential Moving Average of symbol TQQQ on the Open price.
- How do I compute the 21 day Exponential Moving Average of symbol TQQQ on the Open price? Currently I am doing this:
self.ema = self.EMA("TQQQ", 21 * 8, Resolution.Hour)
But how do I specify that I want the EMA to be applied only to the Open Price of TQQQ for the last 21 days? Is it correct to multiple by 8 (21 days times 8 hours/trading day) - to get to the 21 day average?
With Yahoo charts you can specify it as such:
Fred Painchaud
Hi Etay,
Use this:
self.ema = self.EMA("TQQQ", 21 * 8, Resolution.Hour, Field.Open)
Fred
Fred Painchaud
Hi again,
Forgot to answer your second question. For day, you can use the daily resolution. As such:
self.ema = self.EMA("TQQQ", 21, Resolution.Day, Field.Open)
Yes, even if you used AddEquity with Hour resolution. If you do, you get hour bars in OnData, but your ema is daily. So yes, you do a multi-timeframe EMA right away…
Fred
Etay Luz
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!