diff --git a/ChanKLU.py b/ChanKLU.py index 8a5a9f8..411312c 100644 --- a/ChanKLU.py +++ b/ChanKLU.py @@ -46,6 +46,9 @@ class ChanKLU: self.near0_return = 0 self.ema52 = 0 self.ema24 = 0 + self.ema104 = 0 + self.ema156 = 0 + self.ema208 = 0 self.macd_slop = 0 self.signal_slop = 0 self.hist_slop = 0 @@ -110,13 +113,38 @@ class ChanKLU: def set_idx(self, idx): self.idx = idx self.index = idx - + def check_price_ema156(self): + if self.check_indicators(): + if self.close > self.ema156: + return 1 + elif self.close < self.ema156: + return -1 + else: + return 0 + else: + return 0 + def ema_pattern(self): + if self.check_indicators(): + if self.ema24 > self.ema52 and self.ema52 > self.ema104 and self.ema104 > self.ema156: + return 1 + elif self.ema24 < self.ema52 and self.ema52 < self.ema104 and self.ema104 < self.ema156: + return -1 + else: + return 0 + def check_indicators(self): + if self.ema156 == 0: + return False + else: + return True def set_indicators(self, item): self.macd = float(item['macd']) if 'macd' in item and item['macd'] else 0 self.signal = float(item['macdsignal']) if 'macdsignal' in item and item['macdsignal'] else 0 self.macdhist = float(item['macdhist']) if 'macdhist' in item and item['macdhist'] else 0 self.ema52 = float(item['ema52']) if 'ema52' in item and item['ema52'] else 0 self.ema24 = float(item['ema24']) if 'ema24' in item and item['ema24'] else 0 + self.ema104 = float(item['ema104']) if 'ema104' in item and item['ema104'] else 0 + self.ema156 = float(item['ema156']) if 'ema156' in item and item['ema156'] else 0 + self.ema208 = float(item['ema208']) if 'ema208' in item and item['ema208'] else 0 self.rsi = float(item['rsi']) if 'rsi' in item and item['rsi'] else 0 self.volume_ratio = float(item['volume_ratio']) if 'volume_ratio' in item and item['volume_ratio'] else 0 self.bb52upper = float(item['bb52upper']) if 'bb52upper' in item and item['bb52upper'] else 0 diff --git a/ChanLun.py b/ChanLun.py index 0ff5ee8..3ecf133 100644 --- a/ChanLun.py +++ b/ChanLun.py @@ -23,7 +23,7 @@ class ChanLun(): self.time10m = 10 self.time15m = 15 self.time30m = 30 - self.time_m_intervals = [3, 5, 10, 15, 30] + self.time_m_intervals = [2, 3, 5, 10, 15, 20, 30] self.time_m_symbols = ['2m', '3m', '5m', '10m', '15m', '20m','30m'] self.time2h = 2*60 self.time4h = 4*60 diff --git a/TF_DF.py b/TF_DF.py index fafb920..fb4d3ca 100644 --- a/TF_DF.py +++ b/TF_DF.py @@ -98,6 +98,9 @@ class TF_DF(): df['ema10'] = ta.EMA(df, timeperiod=10) df['ema24'] = ta.EMA(df, timeperiod=24) df['ema52'] = ta.EMA(df, timeperiod=52) + df['ema104'] = ta.EMA(df, timeperiod=104) + df['ema156'] = ta.EMA(df, timeperiod=156) + df['ema208'] = ta.EMA(df, timeperiod=208) df['rsi'] = ta.RSI(df, timeperiod=14) df['volume_ratio'] = self.cal_volume_ratio(df) return df