The weights of this moving average are the sums of distances between points. Good luck!
Adopted to Pine from systemtradersuccess.com They wrote that this average is designed to be a robust version of a moving average to reduce the impact of outliers, but I dont see a significant difference comparing it with SMA. So, I published it for the educational purposes. To learn more about the robust filters and averages google Hampel Filter, Interquartile...
This indicator was created by Fábio Figueiredo (VLAD) The idea is to show the distance in percentage that the asset is of the SMA of the price, so it is possible to know if the price is very stretched or not I also added the SMA of "distance of SMA" as extra information.
This indicator was described by John F. Ehlers in his book "Rocket Science for Traders" (2001, Chapter 18: Ehlers Filters).
I do not know good english for explanation sorry. Percentage distance of price to 21ma. Percentage distance of 21ma to 55ma if such a thing is needed, it's here