Hi
I want to get MACD values for 15min Time-frame. As I have created the code below but it is not giving the MACD values correctly.
Orders are place every 15 minute and are liquidated in the very next 15 min candle.
Please let me know where i am doing wrong?
Thanks for the help in advance.
Regards!
Rahul Chowdhury
Hey Praveen,
The algorithm is liquidating early because the MACD indicator as it is defined is using minute resolution data instead of 30-min data. This means the MACD is being updated quickly between long and short signals.
When we create a indicator using a helper method like self.MACD
self.macd = self.MACD("SPY", 12, 26, 9, MovingAverageType.Exponential)
It is automatically subscribed to the default data resolution of SPY, which is minute resolution.Instead we need to first create a "blank" indicator using the indicator constructor and then register it to our 30-min consolidator.
self.macd = MovingAverageConvergenceDivergence(12, 26, 9, MovingAverageType.Exponential) self.RegisterIndicator("SPY", self.macd, thirtyMinuteConsolidator)
Learn more in the documentation on indicators.
Also keep in mind, it is best practice to use self.Debug or self.Log to print messages. You can learn more about this in the documentation on logging and debugging.
Best
Rahul
Praveen Sundriyal
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!