Esempio n. 1
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
Esempio n. 2
0
    def __init__(self):
        self.benchmark = self.getdatabyname(self.p.benchmark_name)
        self.channel = rscch.RSCCH(self.data0,self.benchmark,subplot=False)
        self.rsh = self.channel.rsh
        self.rsl = self.channel.rsl

        self.order = None

        self.bar_counter = 0
Esempio 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 = {}
Esempio n. 4
0
    def __init__(self):

        self.inds = dict()
        self.benchmark = self.getdatabyname(self.p.benchmark_name)

        for d in self.datas:
            if d._name == self.p.benchmark_name:
                continue

            self.inds[d] = dict()

            self.inds[d]['channel'] = rscch.RSCCH(d,
                                                  self.benchmark,
                                                  subplot=False)
            self.inds[d]['rsh'] = self.inds[d]['channel'].rsh
            self.inds[d]['rsl'] = self.inds[d]['channel'].rsl

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

        self.bar_counter = 0
Esempio n. 5
0
    def __init__(self):

        # Initial variables
        self.rscch = rscch.RSCCH(self.data0, self.data1, subplot=False)
        self.l.rsh = self.rscch.l.rsh
        self.l.rsl = self.rscch.l.rsl

        # Check condition for modifying the indicator
        self.rshh_condition = btind.CrossDown(self.data0.low, self.l.rsl)
        self.rsll_condition = btind.CrossUp(self.data0.high, self.l.rsh)

        # Checking candles where High >= RSH, Low <= RSL
        self.over_rsh = btind.Cmp(self.data0.high, self.l.rsh)
        self.under_rsl = btind.Cmp(self.l.rsl, self.data0.low)

        # Misc Variables
        self.start = True
        # Start of ranges. Change when condition met
        self.hstart = 0
        self.lstart = 0

        self.hfirst = True
        self.lfirst = True