Created
July 23, 2020 12:41
-
-
Save unshifty/4f220e07b47b62afa6d7fb02a02be8a7 to your computer and use it in GitHub Desktop.
Pinescript jurik ma
This file contains hidden or 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
jmapower = input(title="JMA Power", type=input.integer, defval=2) | |
jmaphase = input(title="Phase", type=input.integer, defval=50) | |
jma(src, length, phase, power) => | |
phaseRatio = phase < -100 ? 0.5 : phase > 100 ? 2.5 : phase / 100 + 1.5 | |
beta = 0.45 * (length - 1) / (0.45 * (length - 1) + 2) | |
alpha = pow(beta, power) | |
jma = 0.0 | |
e0 = 0.0 | |
e0 := (1 - alpha) * src + alpha * nz(e0[1]) | |
e1 = 0.0 | |
e1 := (src - e0) * (1 - beta) + beta * nz(e1[1]) | |
e2 = 0.0 | |
e2 := (e0 + phaseRatio * e1 - nz(jma[1])) * pow(1 - alpha, 2) + pow(alpha, 2) * nz(e2[1]) | |
jma := e2 + nz(jma[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment