Skip to content

Instantly share code, notes, and snippets.

@yongghongg
Created June 19, 2021 13:42
Show Gist options
  • Save yongghongg/e56a7c7886e36c2255bdb7727453ff50 to your computer and use it in GitHub Desktop.
Save yongghongg/e56a7c7886e36c2255bdb7727453ff50 to your computer and use it in GitHub Desktop.
# function to check for EMA Bounce
def check_bounce_EMA(df):
candle1 = df.iloc[-1]
candle2 = df.iloc[-2]
cond1 = candle1['EMA18'] > candle1['EMA50'] > candle1['EMA100']
cond2 = candle1['STOCH_%K(5,3,3)'] <= 30 or candle1['STOCH_%D(5,3,3)'] <= 30
cond3 = candle2['Low'] < candle2['EMA50'] and \
candle2['Close'] > candle2['EMA50'] and \
candle1['Low'] > candle1 ['EMA50']
return cond1 and cond2 and cond3
# price_chart_df is from Section 2.3
print(check_bounce_EMA(price_chart_df))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment