I'm a python developer but new to the platform. I have a project for a client and I need some high level guidance on how to approach it.
I need to detect when a 5-minute moving average crosses a 20-minute moving average. My thinking is I'll use MovingAverageType, and then watch for a cross in their values, then fire a Notification webhook to my client's endpoint.
Is this the best approach? Is there a "cross" indicator built-in?
Are there things to watch out for?
Thanks!
Fireball
I think this an example algorithm that you are looking for.
As for firing a webhook, I think you can find the information here. You would just replace the setholdings with the webhook in the algorithm.
https://www.quantconnect.com/docs/live-trading/notifications#Notifications-Webhook-NotificationsDavid Swearingen
I forgot to ask: in order to detect a cross, I need to compare the current moving average to the prior one - how do I preserve state from one onData to the next? Can I simply set a variable on self and retrieve it during the next onData event?
Fireball
I think that would work, or you could implement a Rolling Window to reference previous values. You can find more information here;
https://www.quantconnect.com/docs/algorithm-reference/rolling-windowAs well as plenty of example rolling window algorithms on the forum.
David Swearingen
I have just found this which looks like what I need.
https://www.quantconnect.com/forum/discussion/1013/moving-average-cross-in-python
Fireball
Nice!!
David Swearingen
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!