Example #1
0
    def __init__(self):
        macd = self.p.movav(self.data, period=self.p.fastPeriod) - self.p.movav(self.data, period=self.p.slowPeriod)
        high = btind.Highest(self.data, period=self.p.kPeriod)
        low = btind.Lowest(self.data, period=self.p.kPeriod)
        fastk1= btind.If(high-low > 0, (self.data(0)-low) / (high-low) * 100, 0)
        fastd1 = self.p.movav(fastk1, period=self.p.dPeriod)

        high2 = btind.Highest(fastd1, period=self.p.kPeriod)
        low2 = btind.Lowest(fastd1, period=self.p.kPeriod)
        fastk2 = btind.If(high2-low2 > 0, (fastd1(0)-low2) / (high2-low2) * 100, 0)
        self.lines.trend = self.p.movav(fastk2, period=self.p.dPeriod)
Example #2
0
    def __init__(self):
        dmi = btind.DirectionalMovementIndex(self.data, period=self.p.period)
        osc = dmi.plusDI - dmi.minusDI
        hh = btind.Highest(osc, period=self.p.sumperiod)
        ll = btind.Lowest(osc, period=self.p.sumperiod)

        self.lines.stoch = btind.SumN(osc - ll, period=self.p.sumperiod) / btind.SumN(hh - ll, period=self.p.sumperiod) * 100
Example #3
0
    def __init__(self):
        highest = btind.Highest(self.data.high, period=self.p.squeeze_period)
        lowest = btind.Lowest(self.data.low, period=self.p.squeeze_period)
        sma = btind.MovAv.SMA(self.data.close, period=self.p.squeeze_period)
        mean = (highest + lowest + sma) / 3.0
        self.l.jack_vortex = btind.MovAv.SMA(
            (self.data.close - mean) / self.data.close,
            period=self.p.squeeze_period)

        super(JackVortex, self).__init__()
Example #4
0
    def __init__(self):
        smallest = btind.Lowest(self.data, period=self.p.lookback)
        highest = btind.Highest(self.data, period=self.p.lookback)
        bulls = (self.data(0) - smallest) / self.data(0)
        bears = (highest - self.data(0)) / self.data(0)

        avgBulls = self.p.movav(bulls, period=self.p.period)
        avgBears = self.p.movav(bears, period=self.p.period)

        self.lines.bulls = self.p.movav(avgBulls, period=self.p.smoothPeriod)
        self.lines.bears = self.p.movav(avgBears, period=self.p.smoothPeriod)
Example #5
0
    def next(self):

        if self.start:
            self.l.rshh[0] = 0
            self.l.rsll[0] = 0
            self.start = False
        else:
            self.l.rshh[0] = self.l.rshh[-1]
            self.l.rsll[0] = self.l.rsll[-1]
            self.hstart += 1
            self.lstart += 1

        # If RSHH Condition true
        if self.rshh_condition[0]:
            if self.hfirst:
                hi = btind.Highest(self.data0.high, period=self.hstart, subplot=False)
                self.l.rshh = hi
                self.hfirst = False
            else:
                eligible = None
                for i in range(1, self.hstart + 1):
                    if self.over_rsh[-i] == 1:
                        if eligible is None:
                            eligible = self.data0.high[-i]
                        elif self.data0.high[-i] > eligible:
                            eligible = self.data0.high[-i]

                if eligible is not None:
                    self.l.rshh[0] = eligible
            self.hstart = 0

        # If RSLL Condition true
        if self.rsll_condition[0]:
            if self.lfirst:
                lo = btind.Lowest(self.data0.low, period=self.lstart, subplot=False)
                self.l.rsll = lo
                self.lfirst = False
            else:
                eligible = None
                for i in range(1, self.lstart + 1):
                    if self.under_rsl[-i] == 1:
                        if eligible is None:
                            eligible = self.data0.low[-i]
                        elif self.data0.low[-i] < eligible:
                            eligible = self.data0.low[-i]

                if eligible is not None:
                    self.l.rsll[0] = eligible
            self.lstart = 0
Example #6
0
 def __init__(self):
     self.order = None
     self.buyprice = 0
     self.comm = 0
     self.buy_size = 0
     self.buy_count = 0
     # 用到的指标
     self.H_line = bi.Highest(self.data.high(-1), period=self.p.long_period)
     self.L_line = bi.Lowest(self.data.low(-1), period=self.p.long_period)
     self.TR = bi.Max((self.data.high(0) - self.data.low(0)),
                      abs(self.data.close(-1) - self.data.high(0)),
                      abs(self.data.close(-1) - self.data.low(0)))
     self.ATR = bi.SimpleMovingAverage(self.TR, period=14)
     # 价格与上下轨线交叉
     self.buy_signal = bt.ind.CrossOver(self.data.close(0), self.H_line)
     self.sell_signal = bt.ind.CrossOver(self.data.close(0), self.L_line)
    def __init__(self):
        super(Donch, self).__init__()

        # To control operation entries
        self.order = None
        self.startcash = self.broker.getvalue()
        self.accpoints = 0
        self.long = None

        # Create SMA on 2nd data
        self.data_hhv = btind.Highest(self.data.high,
                                      period=self.p.period,
                                      subplot=False)
        self.data_llv = btind.Lowest(self.data.low,
                                     period=self.p.period,
                                     subplot=False)

        self.init_tradeid()
Example #8
0
    def __init__(self):
        super().__init__()
        # self.ema_short = btind.MovAv.EMA(self.data.close, period=self.p.ema_short_period)
        self.atr = btind.ATR(self.data, period=self.p.atr_period)
        self.stddev = btind.StdDev(self.data.close,
                                   period=self.p.stddev_period)
        self.highest = btind.Highest(self.data.high,
                                     period=self.p.squeeze_period,
                                     plot=False)
        self.lowest = btind.Lowest(self.data.low,
                                   period=self.p.squeeze_period,
                                   plot=False)
        self.sma = btind.MovAv.SMA(self.data.close,
                                   period=self.p.squeeze_period,
                                   plot=False)
        self.mean = ((self.highest + self.lowest) / 2.0 + self.sma) / 2.0
        self.squeeze = btind.MovAv.SMA(
            (self.data.close - self.mean) / self.data.close,
            period=self.p.squeeze_period)

        #    self.macd_fast   = btind.MovAv.EMA(self.data.close, period=self.p.macd_fast_period, plot=False)
        #    self.macd_slow   = btind.MovAv.EMA(self.data.close, period=self.p.macd_slow_period, plot=False)
        #    self.macd        = self.macd_fast - self.macd_slow
        #    self.macd_signal = btind.MovAv.EMA(self.macd, period=self.p.macd_signal_period, plot=False)
        #    self.macd_histogram = self.macd - self.macd_signal
        self.macd = btind.MACDHisto(self.data.close,
                                    period_me1=self.p.macd_fast_period,
                                    period_me2=self.p.macd_slow_period,
                                    period_signal=self.p.macd_signal_period)

        self.macd_ema = btind.MovAv.EMA(self.data.close,
                                        period=self.p.macd_ema_period)
        self.stage = self.Start
        self.main_order = None
        self.stop_order = None
        self.limit_order = None
        self.exit_order = None
        self.main_order_price = None
        self.target1_price = None
        self.size = None
        self.symbol_parameter = SymbolParameter(self.p.symbol,
                                                self.broker.get_cash(),
                                                self.p.max_loss_percent)
Example #9
0
    def __init__(self):
        super().__init__()
        # indicators
        self.atr = btind.ATR(self.data, period=self.p.atr_period)
        self.hlc3 = (self.data.high + self.data.low + self.data.close) / 3
        self.baseline = btind.WMA(self.hlc3, period=self.p.baseline_period)
        self.highest_close = btind.Highest(self.data.close,
                                           period=self.p.breakout_period)
        self.lowest_close = btind.Lowest(self.data.close,
                                         period=self.p.breakout_period)

        self.stage = self.Start
        self.main_order = None
        self.stop_order = None
        self.limit_order = None
        self.exit_order = None
        self.main_order_price = None
        self.target1_price = None
        self.size = None
        self.symbol_parameter = SymbolParameter(self.p.symbol,
                                                self.broker.get_cash(),
                                                self.p.max_loss_percent)
Example #10
0
    def start(self):
        self.callcounter = 0
        txtfields = list()
        txtfields.append('Calls')
        txtfields.append('Len Strat')
        txtfields.append('Len Data')
        txtfields.append('Datetime')
        txtfields.append('Open')
        txtfields.append('High')
        txtfields.append('Low')
        txtfields.append('Close')
        txtfields.append('Volume')
        txtfields.append('OpenInterest')
        print(','.join(txtfields))

        self.lcontrol = 0  # control if 1st or 2nd call
        self.inmarket = 0

        # Get the highest but delayed 1 ... to avoid "today"
        self.highest = btind.Highest(self.data.high,
                                     period=self.p.highperiod,
                                     subplot=False)
Example #11
0
    def __init__(self):
        self.buysellLog = ""
        #收盘价、最高价、最低价
        self.dataclose = self.datas[0].close
        self.datahigh = self.datas[0].high
        self.datalow = self.datas[0].low

        self.order = None
        self.buyprice = 0
        self.buycomm = 0
        self.newstake = 0
        self.buytime = 0

        #Donchian channel上下线参数计算(上20,下10)
        self.DonchianHi = btind.Highest(self.datahigh(-1),
                                        period=self.params.maperiod1,
                                        subplot=False,
                                        plotname='上阻力线')
        self.DonchianLo = btind.Lowest(self.datalow(-1),
                                       period=self.params.maperiod2,
                                       subplot=False,
                                       plotname='下支撑线')
        #TR、ATR
        self.TR = btind.Max(self.datahigh - self.datalow,
                            abs(self.datahigh - self.dataclose(-1)),
                            abs(self.dataclose(-1) - self.datalow))
        self.ATR = btind.SimpleMovingAverage(self.TR,
                                             period=14,
                                             subplot=True,
                                             plotname='真实波动幅度均值')
        # Donchian channel上轨突破、下轨突破
        self.CrossoverHi = btind.CrossOver(self.dataclose(0),
                                           self.DonchianHi,
                                           plotname='上阻力线交叉')
        self.CrossoverLo = btind.CrossOver(self.dataclose(0),
                                           self.DonchianLo,
                                           plotname='下支撑线交叉')
Example #12
0
	def __init__(self):
		
		#Set program start time
		start_time=datetime.now().time()
		print('Program start at {}'.format(start_time))
	
		#print(self.params.sma1, self.p.ema1, self.params.atrperiod) #Proof deep copy worked for params
		
		#initialize counters for prenext/next
		self.nextcounter = 0	
		self.counter = 0
		self.counttostop = 0
		self.datastatus = 0
		self.prenext_done = False
		self.bought = 0
		self.sold = 0
		self.target_long_price = 0
		self.target_short_price = 0
		self.trade_open_counter = 0
		self.trade_close_counter = 0	
		self.trade_total_counter = 0
		self.lost_counter = 0 
		self.won_counter = 0
		
		#Define dictionaries and lists to be accessed from all timeframes
		self.atr_list =[]
		self.inds = dict()
		self.gap_dict=dict()
		self.rnghigh_dict = dict()
		self.rnglow_dict= dict()
		self.longstop_dict = dict()
		self.shortstop_dict = dict()
		self.target_long_dict = dict()
		self.target_short_dict = dict()
		self.size_dict = dict()
		self.inorder_dict = dict()		
		self.sup_dict = dict()
		self.res_dict = dict()
		self.pos_dict = defaultdict(list)
				
		#Create/Instantiate objects to access user input parameters
		modelp = UserInputs.model_params()
		indp = UserInputs.ind_params()
		datalist = UserInputs.datalist('hist')
		ibdatalist = UserInputs.datalist('ib')
		
		#Determine interval for timeframe looping
		if not modelp.get('live_status'):
			data_feed_count = len(self.datas)
			ticker_count = len(datalist)
			self.ticker_interval = int(data_feed_count/ticker_count) #Needs to be an integer
		elif modelp.get('live_status'):   
			data_feed_count = len(self.datas)
			ticker_count = len(ibdatalist)
			self.ticker_interval = int(data_feed_count/ticker_count) #Needs to be an integer
		
		#************************INITITIALIZE INDICATORS*********************************************************
		#Initialize dictionary's
		for x in range(0, len(self.datas), self.ticker_interval):
			
			d = self.datas[x]
			print(d._name)
			
			if not (d._name[:-1]=='VIX' or d._name[:-1]=='TICK-NYSE'):
				#Order dictionaries
				self.target_long_dict[d._name] = dict()
				self.target_short_dict[d._name] = dict()
				self.inorder_dict[d._name] = dict()
				self.target_long_dict[d._name] = 0
				self.target_short_dict[d._name] = 0
				self.inorder_dict[d._name] = False
	
		for i, d in enumerate(self.datas): 	
			if not (d._name[:-1]=='VIX' or d._name[:-1]=='TICK-NYSE'):
				#Sizing dictionary
				self.size_dict[d._name] = dict()
				self.size_dict[d._name] = 0
				
				#For support/resistance dictionaries
				self.sup_dict[d._name] = dict()
				self.res_dict[d._name] = dict()
				self.sup_dict[d._name] = 0
				self.res_dict[d._name] = 10000
				
				#For all indicators
				self.inds[d._name] = dict()

				#Moving Average Indicators - FAST, SLOW, and CROSS
				self.inds[d._name]['sma1'] = btind.SMA(d,
														period=indp.get('sma1'),
														plot=False)
														
				self.inds[d._name]['sma2'] = btind.SMA(d,
														period=indp.get('sma2'),
														plot=True)										
				
				self.inds[d._name]['ema1'] = btind.EMA(d,
														period=indp.get('ema1'),
														plot=False)
															
				self.inds[d._name]['ema2'] = btind.EMA(d,
														period=indp.get('ema2'),
														plot=False)
													
				self.inds[d._name]['ema3'] = btind.EMA(d,
														period=indp.get('ema3'),
														plot=False)
				
				#This will double pre-next 												
				self.inds[d._name]['cross'] = btind.CrossOver(self.inds[d._name]['ema2'],
														self.inds[d._name]['ema3'],
														plot=False)
					
				#RSI
				self.inds[d._name]['rsi']= btind.RSI(d,
													safediv=True,
													plot=True)
							
				#AVERAGE TRUE RANGE INDICATOR
				self.inds[d._name]['atr'] = btind.ATR(d,
												period=indp.get('atrperiod'),
												plot=False)

				#Bollinger Band
				self.inds[d._name]['bollinger'] = btind.BollingerBands(d,
															period=indp.get('bollinger_period'),
															devfactor = indp.get('bollinger_dist'),
															plot=False)
			
				#Stochastics
				self.inds[d._name]['stochastic'] = btind.StochasticFast(d,
															period=indp.get('stoch_per'),
															period_dfast= indp.get('stoch_fast'),
															safediv=True,
															plot=True)
				
				#ADX
				self.inds[d._name]['adx'] = btind.ADX(d,plot=True)
						
				"""											
				#Pivots
				self.inds[d._name]['pivots'] = btind.pivotpoint.PivotPoint(d,
															plot=False)
				"""												
				#Average Volume Indicator
				self.inds[d._name]['avg_volume'] = btind.Average(d.volume,
															period=indp.get('avg_per'),
															plot=False)
				
				#Highest and Lowest Values of Period Indicator
				self.inds[d._name]['highest'] = btind.Highest(d.high,
															period=indp.get('breakout_per'),
															plot=False)
																								
				self.inds[d._name]['lowest'] = btind.Lowest(d.low,
															period=indp.get('breakout_per'),
															plot=False)
				
				#Slope indicators
				self.inds[d._name]['slope']= btind.Slope(d.close,
														period=indp.get('slope_period'),
														plot=False)
														
				self.inds[d._name]['slope_sma1'] = 	btind.Slope(self.inds[d._name]['sma1'],
														period=indp.get('slope_period'),
														plot=False,
														plotname = 'Slope_SMA1')
														
				self.inds[d._name]['slope_of_slope_sma1'] = 	btind.Slope(self.inds[d._name]['slope_sma1'],
														period=indp.get('slope_period'),
														plot=False,
														plotname = 'Slope_of_Slope_SMA1')
														
				self.inds[d._name]['slope_sma_width'] = btind.Slope(self.inds[d._name]['sma1']-self.inds[d._name]['sma2'],
														period=indp.get('slope_period'),
														plot=False,
														plotname = 'Slope_SMA_WIDTH')											
														
				self.inds[d._name]['slope_adx'] = 	btind.Slope(self.inds[d._name]['adx'],
														period=indp.get('slope_period'),
														plot=False,
														plotname = 'Slope_ADX')	
														
				self.inds[d._name]['slope_of_slope_adx'] = 	btind.Slope(self.inds[d._name]['slope_adx'],
														period=indp.get('slope_period'),
														plot=False,
														plotname = 'Slope_of_Slope_ADX')	
														
				self.inds[d._name]['slope_rsi'] = 	btind.Slope(self.inds[d._name]['rsi'],
														period=indp.get('slope_period'),
														plot=False,
														plotname = 'Slope_RSI')
														
				self.inds[d._name]['slope_of_slope_rsi'] = 	btind.Slope(self.inds[d._name]['slope_rsi'],
														period=indp.get('slope_period'),
														plot=False,
														plotname = 'Slope_of_Slope_RSI')									
														
				self.inds[d._name]['slope_ema1'] = 	btind.Slope(self.inds[d._name]['ema1'],
														period=indp.get('slope_period'),
														plot=False,
														plotname = 'Slope_EMA1')
				self.inds[d._name]['slope_ema2'] = 	btind.Slope(self.inds[d._name]['ema2'],
														period=indp.get('slope_period'),
														plot=False,
														plotname = 'Slope_EMA2')
				self.inds[d._name]['slope_ema3'] = 	btind.Slope(self.inds[d._name]['ema3'],
														period=indp.get('slope_period'),
														plot=False,
														plotname = 'Slope_EMA3')
				
				#Plot ADX and Slope on same subplot as stochastic							
				self.inds[d._name]['adx'].plotinfo.plotmaster = self.inds[d._name]['rsi']
Example #13
0
	def __init__(self):
		
		#Set program start time
		start_time=datetime.now().time()
		print('Program start at {}'.format(start_time))
		print('Program time period: {} to {}'.format( UserInputs.model_params().get('start_date'),
																	UserInputs.model_params().get('end_date')))
		print('Program Parameters: {}'.format(self.params._getitems()))
		
		#initialize counters for prenext/next
		self.dayperiod = 0
		self.nextcounter = 0	
		self.counter = 0	
		self.prenext_done = False
		self.target_short_price = 0
		self.target_long_price = 0
		self.pos = 0
		self.cash_avail = 0
		self.rng_high = 0
		self.rng_low = 0
		self.tick_close = 0

		#Define dictionaries and lists to be accessed from all timeframes
		self.inds = dict()
		self.rnghigh_dict = dict()
		self.rnglow_dict= dict()
		self.longstop_dict = dict()
		self.shortstop_dict = dict()
		self.target_long_dict = defaultdict(list)
		self.target_short_dict = defaultdict(list)
		self.size_dict = defaultdict(list)
		self.inorder_dict = defaultdict(list)	

		#Create/Instantiate objects to access user input parameters
		self.modelp = UserInputs.model_params()
		datalist = UserInputs.datalist('hist')
		ibdatalist = UserInputs.datalist('ib')
		
		self.data_feed_count = len(self.datas)
		#Determine interval for timeframe looping
		if not self.modelp.get('live_status'):
			self.ticker_count = len(datalist)
			self.number_timeframes = int(self.data_feed_count/self.ticker_count) #Needs to be an integer
		elif self.modelp.get('live_status'):   
			self.ticker_count = len(ibdatalist)
			self.number_timeframes = int(self.data_feed_count/self.ticker_count) #Needs to be an integer
		
		self.minimum_data = int(self.ticker_count * self.modelp.get('timeframe2')/self.modelp.get('timeframe0'))  #since iterating over 5 min periods, and longest timeframe is 1 hour, there are 12 5 min periods in an hour
	
		#Determine # of base timeframe periods within trading day
		self.intraday_periods = int(390/self.modelp.get('timeframe0'))
		
		#************************INITITIALIZE INDICATORS*********************************************************
		#Initialize dictionary's	
		for i, d in enumerate(self.datas):
			
			print("Datas in Strategy {}".format(d._name))
			
			self.name_t0 = d._name[:-1]+'0'
			self.name_t1 = d._name[:-1]+'1'
			self.name_t2 = d._name[:-1]+'2'
			
			#Initialize dictionaries by appending 0 value
			self.target_long_dict[d._name].append(0)
			self.target_short_dict[d._name].append(0)
			self.size_dict[d._name].append(0)  #Need to append twice to reference 2nd to last value
			self.size_dict[d._name].append(0) 
			self.inorder_dict[d._name].append(False)
			
			#Get available cash
			self.cash_avail = round(self.broker.getcash(),2)
			
		
			#For all indicators
			self.inds[d._name] = dict()
			
							
			#Determine on balance volume
			self.inds[d._name]['obv'] = btind.obv(d,
											period=self.p.obv,
											plot=True)
			
			#Determine current ohlcv bars
			self.inds[d._name]['ohlc'] = btind.ohlc(d,
											period=self.p.ohlc,
											plot=False)
	
			
			#Determine prior day bars
			self.inds[d._name]['prior_ohlc'] = btind.priorday(d,
											period=self.p.ohlc,
											plot=False)
			
										
			#Determine opening gap and opening hi/low range (defined by b_time parameter)
			self.inds[d._name]['gap'] = btind.gap(d,
											period=self.p.breakout_per,
											plot=False)
			
			#AVERAGE TRUE RANGE INDICATOR
			self.inds[d._name]['atr'] = btind.ATR(d,
											period=self.p.atrperiod,
											plot=False)
											
			#Moving Average Indicators - FAST, SLOW, and CROSS
			self.inds[d._name]['sma1'] = btind.SMA(d,
													period=self.p.sma1,
													plot=False)
													
			self.inds[d._name]['sma2'] = btind.SMA(d,
													period=self.p.sma2,
													plot=False)										
			
			
			self.inds[d._name]['ema1'] = btind.EMA(d,
													period=self.p.ema1,
													plot=True)
														
			self.inds[d._name]['ema2'] = btind.EMA(d,
													period=self.p.ema2,
													plot=True)
																				
			self.inds[d._name]['cross'] = btind.CrossOver(self.inds[d._name]['ema1'],
													self.inds[d._name]['ema2'],
													plot=False)
			"""
			#RSI
			self.inds[d._name]['rsi']= btind.RSI(d,
												safediv=True,
												plot=False)
					
			
			#Bollinger Band
			self.inds[d._name]['bollinger'] = btind.BollingerBands(d,
														period=self.p.bollinger_period,
														devfactor = self.p.bollinger_dist'),
														plot=False)
	
			"""
			#Stochastics - just prints Slow %d line (not %K also which would be "StochasticFast")
			self.inds[d._name]['stochastic'] = btind.StochasticSlow(d,
														period=self.p.stoch_per,
														period_dfast= self.p.stoch_fast,
														safediv=True,
														plot=False)
			
			#ADX
			self.inds[d._name]['adx'] = btind.ADX(d,
												period=self.p.adx,
												plot=False)
			"""												
			#Pivots
			self.inds[d._name]['pivots'] = btind.pivotpoint.PivotPoint(d,
														plot=False)
			"""											
		
			#Highest and Lowest Values of Period Indicator
			self.inds[d._name]['highest'] = btind.Highest(d.high,
														period=self.p.breakout_per,
														plot=False)
																							
			self.inds[d._name]['lowest'] = btind.Lowest(d.low,
														period=self.p.breakout_per,
														plot=False)
			
			#Slope indicators
			self.inds[d._name]['slope']= btind.Slope(d.close,
													period=self.p.slope_period,
													plot=False)
													
			self.inds[d._name]['slope_obv'] = 	btind.Slope(self.inds[d._name]['obv'],
												period=self.p.slope_period,
												plot=False)
												
			self.inds[d._name]['slope_of_slope_obv'] = 	btind.Slope(self.inds[d._name]['slope_obv'],
												period=self.p.slope_period,
												plot=False)	
				
			
			self.inds[d._name]['slope_sma1'] = 	btind.Slope(self.inds[d._name]['sma1'],
													period=self.p.slope_period,
													plot=False)									
													
			self.inds[d._name]['slope_of_slope_sma1'] = btind.Slope(self.inds[d._name]['slope_sma1'],
													period=self.p.slope_period,
													plot=False)
													
			
			"""										
			self.inds[d._name]['slope_of_slope_sma1'] = btind.Slope(self.inds[d._name]['slope_sma1'],
													period=self.p.slope_period,
													plot=False)
													
			self.inds[d._name]['slope_sma_width'] = btind.Slope(self.inds[d._name]['sma1']-self.inds[d._name]['sma2'],
													period=self.p.slope_period,
													plot=False)											
													
			self.inds[d._name]['slope_adx'] = 	btind.Slope(self.inds[d._name]['adx'],
													period=self.p.slope_period,
													plot=False)	
													
			self.inds[d._name]['slope_of_slope_adx'] = 	btind.Slope(self.inds[d._name]['slope_adx'],
													period=self.p.slope_period,
													plot=False)	
													
			self.inds[d._name]['slope_rsi'] = 	btind.Slope(self.inds[d._name]['rsi'],
													period=self.p.slope_period,
													plot=False,
													plotname = 'Slope_RSI')
													
			self.inds[d._name]['slope_of_slope_rsi'] = 	btind.Slope(self.inds[d._name]['slope_rsi'],
													period=self.p.slope_period,
													plot=False,
													plotname = 'Slope_of_Slope_RSI')									
													
			self.inds[d._name]['slope_ema1'] = 	btind.Slope(self.inds[d._name]['ema1'],
													period=self.p.slope_period,
													plot=False,
													plotname = 'Slope_EMA1')
			self.inds[d._name]['slope_ema2'] = 	btind.Slope(self.inds[d._name]['ema2'],
													period=self.p.slope_period,
													plot=False,
													plotname = 'Slope_EMA2')
			"""
													
			self.inds[d._name]['resistance'] = btind.Resistance(d,
															period=self.p.lookback,
															min_touches = self.p.min_touches,
															tolerance_perc = self.p.tolerance_perc,
															bounce_perc = self.p.bounce_perc,
															plot=True)	
			
			self.inds[d._name]['support'] = btind.Support(d,
															period=self.p.lookback,
															min_touches = self.p.min_touches,
															tolerance_perc = self.p.tolerance_perc,
															bounce_perc = self.p.bounce_perc,
															plot=True)
			
			if d._name == d._name[:-1]+'0':
				self.inds[d._name]['priorday'] = btind.priorday(d,
															period=self.p.priorday,
															plot=False)
			
			#Calculate VWAP																			
			self.inds[d._name]['vwap'] = btind.vwap(d,
													period=self.p.vwap_lookback,
													plot=True)
			
			#Calculate Hammer Candle Signal								
			if not d._name == 'TICK-NYSE0':	
				self.inds[d._name]['hammer'] = btind.HammerCandles(d,
														plot=False)											

			#Plot ADX and Stochastic on same subplot as stochastic							
			#self.inds[d._name]['adx'].plotinfo.plotmaster = self.inds[d._name]['stochastic']
		
		print('Start preloading data to meet minimum data requirements')	
Example #14
0
 def __init__(self):
     self.lines.top = btind.Highest(self.data.high, period=self.p.period)
     self.lines.bot = btind.Lowest(self.data.low, period=self.p.period)
     self.lines.mid = (self.lines.top(0) + self.lines.bot(0)) / 2
Example #15
0
 def __init__(self):
     price = btind.MovingAverageSimple(self.data, period=self.p.period)
     roc = 100 * (price(0) / price(-self.p.period)-1)
     maxvol = btind.Highest(self.data.volume, period=self.p.period)
     self.lines.effort = roc / maxvol