def __init__(self): self.benchmark = self.getdatabyname(self.p.benchmark_name) # Initialize & assign Indicators here # self.rsc_channel = rscu.rscu(self.data0,self.benchmark,subplot=False) self.dmich = dmi_inds.DMICH(self.data0,subplot=False)
def __init__(self): self.benchmark = self.getdatabyname(self.p.benchmark_name) # Initialize & assign Indicators here self.rscupdown = rscu.rscu(self.data0, self.benchmark, subplot=False) self.rscch = rscch.RSCCH(self.data0, self.benchmark, subplot=False) self.price_channels = hhpc.PC(self.data0, subplot=False) self.bch = dmi_inds.BCH(self.data0, period=14, subplot=False) self.dmich = dmi_inds.DMICH(self.data0, subplot=False) self.pdih = self.dmich.pdih self.mdil = self.dmich.mdil self.bbh = self.bch.bbh self.rbl = self.bch.rbl self.hhpc = self.price_channels.hhpc self.llpc = self.price_channels.llpc self.rschc = self.rscch.rsh self.rsclc = self.rscch.rsl self.hrscu = self.rscupdown.hrscu self.lrscu = self.rscupdown.lrscu self.hrscd = self.rscupdown.hrscd self.lrscd = self.rscupdown.lrscd self.rsl_last_entry = None self.order = None
def __init__(self): ''' Create an dictionary of indicators so that we can dynamically add the indicators to the strategy using a loop. This mean the strategy will work with any numner of data feeds. ''' self.benchmark = self.getdatabyname(self.p.benchmark_name) self.inds = dict() for i, d in enumerate(self.datas): print('Initializing Indicators for Data :', d._name) if d._name == self.p.benchmark_name: continue self.inds[d] = dict() #Custom Indicators self.inds[d]['dmich'] = dmi_inds.DMICH(d) self.inds[d]['bch'] = dmi_inds.BCH(d) self.inds[d]['rsch'] = rscch.RSCCH(d, self.benchmark) self.inds[d]['pc'] = hhpc.PC(d) # New Custom Indicators self.inds[d]['RSH10'] = bt.indicators.SMA(self.inds[d]['rsch'].rsh, period=10) self.inds[d]['RSL10'] = bt.indicators.SMA(self.inds[d]['rsch'].rsl, period=10) self.inds[d]['ROC1'] = bt.indicators.ROC100(d, period=1) #Standard Indicatora self.inds[d]['sma_close'] = bt.indicators.SMA(d.close, period=50) self.inds[d]['vma'] = bt.indicators.SMA(d.volume, period=200) # self.inds[d]['RSCMA5'] = bt.indicators.SMA(self.inds[d]['rsch'].rsc,period=5) self.inds[d]['RSCMA10'] = bt.indicators.SMA( self.inds[d]['rsch'].rsc, period=10) self.inds[d]['RSCMA200'] = bt.indicators.SMA( self.inds[d]['rsch'].rsc, period=200) self.inds[d]['PCH25'] = bt.indicators.basicops.Highest( d.high(-1), period=25) # -1 to not include current bar self.inds[d]['PCL25'] = bt.indicators.basicops.Lowest(d.low(-1), period=25) #Cross Conditions RSC self.inds[d]['RSC CU'] = bt.indicators.crossover.CrossUp( self.inds[d]['rsch'].rsc, self.inds[d]['RSCMA10']) self.inds[d]['RSC CD'] = bt.indicators.crossover.CrossDown( self.inds[d]['rsch'].rsc, self.inds[d]['RSCMA10']) # To keep track of pending orders and buy price/commission self.order = None self.buyprice = None self.buycomm = None self.last_values = {} self.data_value_json = {}
def __init__(self): self.inds = dict() for d in self.datas: if d._name == self.p.benchmark_name: continue self.inds[d] = dict() self.inds[d]['dmi_inds'] = dmi_inds.DMICH(d, subplot=False) self.inds[d]['PDIH'] = self.inds[d]['dmi_inds'].l.pdih self.inds[d]['MDIL'] = self.inds[d]['dmi_inds'].l.mdil self.inds[d]['order'] = None # self.tradeNo = 0 # self.counter = 0 # self.eligible = False self.bar_counter = 0 hi, lo = self.data.high, self.data.low