Ejemplo n.º 1
0
    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]['csma200'] = btind.SMA(d.close, period=200)
            self.inds[d]['dmi'] = dmi_inds.BCH(d, subplot=False)
            self.inds[d]['bbh'] = self.inds[d]['dmi'].bbh
            self.inds[d]['adx'] = btind.AverageDirectionalMovementIndex(
                d, period=14, subplot=False)
            self.inds[d]['adxma'] = btind.SMA(self.inds[d]['adx'], period=2)

            self.inds[d]['rbbhl'] = RBBBHL.RBBHL(d, subplot=False)
            self.inds[d]['hbb'] = self.inds[d]['rbbhl'].hbb

            self.inds[d]['order'] = None
            self.inds[d]['sellStop'] = None
            self.inds[d]['onceTrue'] = False
            self.inds[d]['sell_condition'] = btind.crossover.CrossDown(
                self.inds[d]['adx'], self.inds[d]['adxma'])

            self.inds[d]['bar_counter'] = 0
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
    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 = {}
Ejemplo n.º 4
0
    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]['channel'] = dmi_inds.BCH(d, subplot=False)
            self.inds[d]['bbh'] = self.inds[d]['channel'].bbh
            self.inds[d]['rbl'] = self.inds[d]['channel'].rbl

            self.inds[d]['order'] = None

        self.bar_counter = 0