One of the unique aspects of modelling financial time series is that recent data is more important than previous data. This is because forecasts need to be made for the next time period, and prices compound in value over time. The other unique aspect of time series data is that there tends to be a combination of random noise and mean-reverting tendencies (especially at shorter frequencies). The researcher often faces a tradeoff between weighting based on recency versus amplifying the noise and mean-reversion that exists at shorter frequencies. This tradeoff is logical, and should be captured explicitly as a function in an adaptive framework (success-weighted) versus back-testing different weighting schemes hindsight.

Recency is easily captured by a weighted moving average (**wma**). In this scheme, prices are weighted in direct proportion to their recency (the recency rank divided by the sum of recency ranks times the price at time t). This link demonstrates the calculation : http://www.investopedia.com/articles/technical/060401.asp . Alternatively, the best way to eliminate disturbances induced by shorter frequencies is to middle weight the data. That is, we want to give data closest to the middle higher values than more recent data. This is best accomplished using a triangular moving average, which is essentially a moving average of the moving average of the same length. The smoothing induced by a triangular moving average creates maximum weighting on the middle value. The calculation is described here: http://daytrading.about.com/od/indicators/a/Triangular.htm.

To keep things consistent, we should use a weighted triangular moving average (**wtma**), which is exactly the same except it uses the weighted moving average versus the simple moving average in the calculation. Thus the Adaptive Frequency Weighted Moving Average can be calculated simply as:

**AFWMA**= *w**(**wma**)+ (1-*w*)*(**twma**)

where “w” is a constant between 0 and 1

The purpose of the AFWMA is to find the optimal balance between recency and avoiding short-term noise. This can be found by solving for “w” to best minimize out of sample error in a forecast format, or to best maximize out of sample sharpe in a trading strategy format. It is a simple and logical way of compressing the value/information content that differs between the weighted and triangular moving averages without resorting to blind optimization (or worse yet the beliefs/opinions of a technical analysis “guru”).

### Like this:

Like Loading...

*Related*

Very interesting…had not heard of AFWMA before reading your post. Now I will have to look into it some more. Thanks!

can you please put up a code or excel calculation?

Pingback: Afwma - I Forum di Investireoggi

Hi David,

I don’t know if I understood your explanation, could this be the code for Amibroker?

w=0.5;

Odd=13;//enter Odd numbers only

CoefOdd=round(Odd/2);

Even=12;//enter Even numbers only

Coefeven=Even/2;

Coefeven2=Coefeven+1;

CongestionPercent=2.8;/*Set % above/below Moving average for congestion / sideways market*/

TriangularOdd=EMA(EMA(C,CoefOdd),CoefOdd);

TriangularEven=EMA(EMA(C,Coefeven),Coefeven2);

finalMov_avg=IIf(Odd > even,triangularOdd,TriangularEven);

AFWMA=w*WMA(C,13)+(1-w)*finalMov_avg;

Color=colorBrightGreen;//select Moving average line color

tickercolor=colorBlack;//select price color

Plot(AFWMA,””,IIf(C < finalmov_avg,colorRed,Color),styleLine|styleThick);

Plot(C,"",tickercolor,styleCandle);