The proposed moving average can be used like most slow moving averages.
Having a moving average able to converge closer to the price the longer a trend lasts allows users to obtain more timely crosses.
// by LuxAlgo
length=100
incr=10
fast=10
If barindex > length then
//Settings
src = customclose
//Calculations
once ma = 0
once fma = 0
once alpha = 0
once k = 1/incr
upper = highest[length]
lower = lowest[length]
initma = average[length](src)
cross = src crosses under ma or src crosses over ma
If cross then
alpha = 2 /(length+1)
elsif (src > ma and upper > upper[1]) or (src < ma and lower < lower[1]) then
alpha = alpha + k
endif
ma = ma[1] + alpha[1]*(src - ma[1])
If ma = 0 then
ma = initma
endif
If cross then
fma = (src+fma[1])/2
elsif src > ma then
fma = MAX(src,fma[1])+((src-fma[1])/fast)
else
fma = MIN(src,fma[1])+((src-fma[1])/fast)
Endif
If fma = 0 then
fma = src
endif
If fma > ma then
r = 10
g = 255
b = 10
else
r = 255
g = 10
b = 10
Endif
Colorbetween(fma,ma,r,g,b,30)
Endif
Return fma coloured("red",100), ma style(line,3)coloured (r,g,b,255)