Back

Composite Indicators in python and where to find descriptions of indicator methods

I am trying to create composite indicators and I have seen various iterations of c# code going back to 2015 in the forum but I am having trouble translating these to current code using python. Here is a sample of code but it produces the error 

 

During the algorithm initialization, the following exception has occurred: AttributeError : 'ExponentialMovingAverage' object has no attribute 'Of' at Initialize in main.py:line 21
AttributeError : 'ExponentialMovingAverage' object has no attribute 'Of'

 

class BasicCIeAlgorithm(QCAlgorithm):
'''Trying to understand the composite indicator in python'''

def Initialize(self):

self.SetStartDate(2010, 1, 1) #Set Start Date
self.SetEndDate(2011, 1, 1) #Set End Date
self.SetCash(1000) #Set Strategy Cash

self.SetWarmUp(40)
self.warmingUp = True

self.symbols = ["SPY"]
for symbol in self.symbols:

self.AddEquity(symbol, Resolution.Daily)

STD14 = self.STD(symbol, 14, Resolution.Daily)
EMA3_SD14 = ExponentialMovingAverage(3).Of(STD14)

def OnData(self, data):
pass

Also I stumpled on the Of() and Over() methods by searching for composite indicator exaples but is there a place/way that I can find reference to all the current methods?

Thanks,

Jim

 

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 Jim.

Use IndicatorExtensions.EMA() to construct the EMA(3) of STD(14):

# In Initialize()
self.spy = self.AddEquity("SPY", Resolution.Daily)

STD14 = self.STD(self.spy.Symbol,14)
EMA3_SD14 = IndicatorExtensions.EMA(STD14,3)

This documentation section on Indicators features examples of how to use Indicator Extensions. Good luck!

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.


Thanks Halldor.

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