Adaptive Exponential Moving Average
expr - data series formula
factor - weighting factor formula
An AEMA is an EMA that supports a variable weighting factor. In other words, an EMA is an AEMA with a constant weight.
The count of an EMA becomes a weight factor using the formula factor = 2 / (count + 1).
Conversely the factor of an AEMA can be converted to a EMA count using count = (2 - factor) / factor.
In both cases the average series is created by repeatedly calculating newAverage = oldAverage + factor * (newValue - oldAverage).
The key difference between the functions is that while the EMA count is evaluated only once before the series of values is calculated, the AEMA factor is reevaluated for every bar of the series, thus making it adaptive.
This function supports ultra-fast one-pass calculation when used in the Data Section with a non-variable count.