In the manual the AMA() entry gives an example of an adaptive moving average.
The central piece of the code recalls Dreiss's work, The Ink, and I get that. Distance travelled versus distance as the crow flies. What I don't get is this line.
sc =( ER*(fast-slow)+slow)^2;
Could you explain what you are doing there?
@BBands I believe that he was using the Perry Kaufman Adaptive Moving Average as an example of how to use the AMA() function. I believe Kaufman first wrote about this idea in his 1995 book "Smarter Trading". Kaufman explains the concept well in his book (and I am sure there must be some articles since then where he also discuss' it? - the June 1995 issue of Technical Analysis of Stocks and Commodities magazine)
That work is indeed discussed in Chapter 8 of "Smarter Trading", but I think that the core concept dates back the Australian commodity analyst E. W. Driess's work on the Choppiness Index. Here is a link to a 1993 write up by Gibbons Burke. http://www.edwards-magee.com/ggu/dreissCI.pdf
you adjust smoothing factor (or "length" of average or cutoff frequency of the filter) so it is "shorter" when volatility is high
The AMA example uses very simple sum of one-bar differences, but @BBands may prefer to use StDev( C, 10 ) as a measure of volatility (since StDev is used for Bollinger Bands ) and call it "Bollinger Adaptive MA"