Hi all,
I'm trying to create a simple moving average indicator with 4 hour resolution. I have tried the following but I have been greeted with the error:
"During the algorithm initialization, the following exception has occurred: Trying to dynamically access a method that does not exist throws a TypeError exception. To prevent the exception, ensure each parameter type matches those required by the SMA method. Please checkout the API documentation."
Any ideas on how to fix this?
class ForexMinuteTrading(QCAlgorithm):
def Initialize(self):
# Generic Initialization
self.SetStartDate(2018, 10, 1)
self.SetCash(100000)
self.SetBrokerageModel(BrokerageName.FxcmBrokerage)
self.symbols = ["EURUSD", "USDJPY", "AUDUSD"]
# Order Related Variables
self.buyOrders = {}
self.stopLoss = {}
self.takeProfit = {}
self.high = {}
# Indicator Related Variables
self.duck1 = {}
self.duck2 = {}
self.duck3 = {}
# Add Forex and the proper Indicators
for symbol in self.symbols:
self.AddForex(symbol, Resolution.Minute, Market.FXCM)
fourHours = QuoteBarConsolidator(timedelta(hours=4))
fourHours.DataConsolidated += self.fourHoursConsolidator
self.duck2[symbol] = self.SMA(symbol, 60, Resolution.Hour)
self.duck3[symbol] = self.SMA(symbol, 60, Resolution.Minute)
self.duck1[symbol] = self.SMA(symbol, 60, fourHours)
self.SetBenchmark("EURUSD")
self.SetWarmUp(100)
Alexandre Catarino
Hi Marc Khristian Partoriza ,
The indicators' helper methods do not accept consolidators as parameters:
self.duck1[symbol] = self.SMA(symbol, 60, fourHours)
We need to create the indicator with its constructor and register it:
self.duck1[symbol] = SimpleMovingAverage(60) self.RegisterIndicator(symbol, self.duck1[symbol], fourHours)
Please check out the docs, under Indicators, for more details.
Pcnpj
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!