Created
February 6, 2016 19:57
-
-
Save graphbear/f1d7a841eb994133f2eb to your computer and use it in GitHub Desktop.
hull moving average
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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