Newbie - strategy for developing notifications on SMA indicators

Back

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!

Update Backtest







 
0

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.


https://www.quantconnect.com/forum/discussion/1013/moving-average-cross-in-python/p1

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-Notifications

 

0

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?

0

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-window

As well as plenty of example rolling window algorithms on the forum.

1

0

Nice!!

0

Update Backtest





0

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.


Loading...

This discussion is closed