Closed N0233 closed 2 years ago
It's ok, getting the last value of a set (xPrice[Length]
in your pinescript) was tricky so I added last
function.
because var[x]
notation only accept static numbers as x
so the script know in advance how many points it will store in var
etc...
→ last(xPrice, options.length)
Try this : indicator_kama.txt
Thank you very much,Tucksy!
np, it's a cool average 🙂
about this line tho :
nAMA = nAMA[1] + nsmooth * (xPrice - nAMA[1])
i'm not sure how TV handle the first value of that variable because me it start at 0 that's why the line start low at the beginning (lower than it should)
but if we make it start at current price it fixes that issue
nAMA = bar.length > 1 ? nAMA[1] + nsmooth * (xPrice - nAMA[1]) : $price.close
Primarily thanks for your platform, Tucsky
I tried for several hours to adapt the Kaufman Moving Average to aggr and couldn't. I would be grateful if someone would write KAMA for Aggr trade. Here's the script from tradingview:
study(title="Kaufman Moving Average Adaptive (KAMA)", shorttitle="Kaufman Moving Average Adaptive (KAMA)", overlay = true) Length = input(21, minval=1) xPrice = close xvnoise = abs(xPrice - xPrice[1]) nAMA = 0.0 nfastend = 0.666 nslowend = 0.0645 nsignal = abs(xPrice - xPrice[Length]) nnoise = sum(xvnoise, Length) nefratio = iff(nnoise != 0, nsignal / nnoise, 0) nsmooth = pow(nefratio (nfastend - nslowend) + nslowend, 2) nAMA := nz(nAMA[1]) + nsmooth (xPrice - nz(nAMA[1])) plot(nAMA, color=color.blue, title="KAMA")