Skip to content

Instantly share code, notes, and snippets.

@jsrimr
Created September 6, 2019 04:53
Show Gist options
  • Save jsrimr/2730fd41c164c415c9a0aed25c296a7f to your computer and use it in GitHub Desktop.
Save jsrimr/2730fd41c164c415c9a0aed25c296a7f to your computer and use it in GitHub Desktop.
def fnMACD(m_Df, m_NumFast=12, m_NumSlow=26, m_NumSignal=9):
EMAFast = m_Df['c'].ewm( span = m_NumFast, min_periods = m_NumFast - 1).mean()
EMASlow = m_Df['c'].ewm( span = m_NumSlow, min_periods = m_NumSlow - 1).mean()
MACD = EMAFast - EMASlow
MACDSignal= MACD.ewm( span = m_NumSignal, min_periods = m_NumSignal-1).mean()
MACDDiff= MACD - MACDSignal
return MACDDiff.mean()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment