Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- // The built-in is ~15x faster than the Pine version.
- study("PP alma built-in vs usr function")
- s = close, l = 4, o = 0.85, g = 6, d = 1
- pine_alma(series, windowsize, offset, sigma) =>
- m = floor(offset * (windowsize - 1))
- s = windowsize / sigma
- norm = 0.0
- sum = 0.0
- for i = 0 to windowsize - 1
- weight = exp(-1 * pow(i - m, 2) / (2 * pow(s, 2)))
- norm := norm + weight
- sum := sum + series[windowsize - i - 1] * weight
- sum / norm
- a = 0.
- for i=1 to 9000
- // a := alma(s+i,l,o,g) //K iterations working: 5 15 25 50 100 125 140, Not working: 200 150 145 140
- a := pine_alma(s+i,l,o,g) //K iterations working: 5 7.5 8.5 9 // Not working: 125 25 15 10
- plot(a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement