Sorry if this is the wrong place to post this but I was wondering if someone could look at this code and comment on if its the correct way to use and ADX indicator in a 5 minute data consolidation? Thanks for your time!
import numpy as np
import datetime
import calendar
class VPPlgorithm(QCAlgorithm):
def Initialize(self):
'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
self.SetStartDate(2013,1,18) #Set Start Date
self.SetEndDate(2013,11,21) #Set End Date
self.SetCash(10000) #Set Strategy Cash
self.AddForex("USDJPY", Resolution.Minute, Market.Oanda)
self.SetBrokerageModel(BrokerageName.OandaBrokerage)
self.adx = AverageDirectionalIndex("USDJPY",14)
fiveMinuteConsolidator = QuoteBarConsolidator(datetime.timedelta(minutes=5))
fiveMinuteConsolidator.DataConsolidated += self.FiveMinuteBarHandler
self.SubscriptionManager.AddConsolidator("USDJPY", fiveMinuteConsolidator)
self.RegisterIndicator("USDJPY", self.adx, fiveMinuteConsolidator)
self.SetWarmUp(5*14, Resolution.Minute)
def FiveMinuteBarHandler(self, sender, consolidated):
if self.adx.IsReady:
self.Log("ADX: " + str(self.adx.Current.Value))
def OnData(self, data):
pass