trophy

Long Only, ETF Alpha Streams Competition with $27,500 Prize Pool      T-17

Back

Rolling Window for Indicators with Multiple Values

Hey guys, I'm trying to expand the RollingWindowAlgorithm.py example to be able to use MACD.  I'm having difficulty trying to pull the different values for Fast and Slow as they don't seem to be accessed the same way as they are outside of the window.  Is there another way these need to be setup or called to be able to use those types of indicators?

I've commented out the lines that set these up so that I could attached the backtest but every time I play around with trying to call the values in different ways they all seem to produce the following error:

Runtime Error: AttributeError : 'IndicatorDataPoint' object has no attribute 'Fast'

Thanks for the help!

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.


Hi Brad,

There are actually many ways to implement your strategy. From your commented line I believe you are on the right track, but just had some type errors. Here is my attempt of implementation:

1. First set up two rolling windows to store the value of macd.fast and macd.slow. Notice that the type of value is float.
 

self._macd["Fast"] = RollingWindow[float](5)
self._macd["Slow"] = RollingWindow[float](5)

2. In the indicator updated event handler, update the two rolling windows.
 

self._macd["Fast"].Add(self.macd.Fast.Current.Value)
self._macd["Slow"].Add(self.macd.Slow.Current.Value)

3. Access the stored value. For example, the current fast value would be:

currMACDfast = self._macd["Fast"][0]


And don't forget to put a IsReady check before accessing rolling window:
 

if not (self._macd["Fast"].IsReady and self._macd["Slow"].IsReady): return

 

1

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.


Awesome! That's exactly what I was looking for.  Thank you for the help!!!

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