Skip to content

Instantly share code, notes, and snippets.

@GraphBear
Created February 6, 2016 19:57
Show Gist options
  • Save GraphBear/f1d7a841eb994133f2eb to your computer and use it in GitHub Desktop.
Save GraphBear/f1d7a841eb994133f2eb to your computer and use it in GitHub Desktop.
hull moving average
def hma(values, window):
# requires wma.py
# HMA = WMA(2*WMA(PRICE, N/2) - WMA(PRICE, N), SQRT(N))
period = int(np.sqrt(window))
# created wma array with NaN values for indexes < window value
# hull_moving_averages = np.empty(window)
# hull_moving_averages[:] = np.NAN
wma1 = 2* wma(values, window/2)
wma2 = wma(values, window)
hull_moving_averages = wma((wma1 - wma2), period)
return hull_moving_averages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment