diff --git a/monitors/move.py b/monitors/move.py index ce3fdda..fdfb0ed 100644 --- a/monitors/move.py +++ b/monitors/move.py @@ -40,8 +40,12 @@ def stratergy_run(symbol, interval, df, debug): d2 = df.iloc[-2] d3 = df.iloc[-3] - isbullish = d1['isLongArrangement'] == True and d2['isLongArrangement'] == True and d3['isLongArrangement'] == False - isBear = d1['isShortArrangement'] == True and d2['isShortArrangement'] == True and d3['isShortArrangement'] == False + maxDiff = max(d1['shortDiff'], d1['midDiff'], d1['longDiff']) + minDiff = min(d1['shortDiff'], d1['midDiff'], d1['longDiff']) + isOffset = maxDiff / minDiff < 3 + + isbullish = d1['isLongArrangement'] == True and d2['isLongArrangement'] == True and d3['isLongArrangement'] == False and isOffset == True + isBear = d1['isShortArrangement'] == True and d2['isShortArrangement'] == True and d3['isShortArrangement'] == False and isOffset == True print(f"{symbol} - {interval} bullish: {isbullish} | bear : {isBear} | LongArrangement: {d1['isLongArrangement']} | ShortArrangement: {d1['isShortArrangement']}") if(isbullish | isBear): diff --git a/test.py b/test.py index 39fa03a..8bfdb95 100644 --- a/test.py +++ b/test.py @@ -14,6 +14,10 @@ df['ema10'] = talib.EMA(df['close'], timeperiod=10) df['ema30'] = talib.EMA(df['close'], timeperiod=30) df['ema144'] = talib.EMA(df['close'], timeperiod=144) +df['shortDiff'] = abs(df['ema5'] - df['ema10']) / df['ema10'] +df['midDiff'] = abs(df['ema10'] - df['ema30']) / df['ema30'] +df['longDiff'] = abs(df['ema30'] - df['ema144']) / df['ema144'] + df['isLongArrangement'] = ((df['ema5'] > df['ema10']) & (df['ema10'] > df['ema30']) & (df['ema30'] > df['ema144'])) df['isShortArrangement'] = ((df['ema5'] < df['ema10']) & (df['ema10'] < df['ema30']) & (df['ema30'] < df['ema144'])) @@ -22,6 +26,9 @@ d2 = df.iloc[-2] d3 = df.iloc[-3] isBear = d1['isShortArrangement'] == True and d2['isShortArrangement'] == True and d3['isShortArrangement'] == False +maxDiff = max(d1['shortDiff'], d1['midDiff'], d1['longDiff']) +minDiff = min(d1['shortDiff'], d1['midDiff'], d1['longDiff']) +isOffset = maxDiff / minDiff < 3 print(df) -print(isBear) \ No newline at end of file +print(isOffset) \ No newline at end of file