Skip to content

Adaptive Frequency Weighted Moving Average (AFWMA)

October 30, 2012

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 : . 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:

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”).

4 Comments leave one →
  1. November 5, 2012 6:41 pm

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

  2. ashvin Patel permalink
    February 15, 2013 1:17 pm

    can you please put up a code or excel calculation?

  3. markettrendchanges permalink
    April 13, 2013 1:26 pm

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

    Odd=13;//enter Odd numbers only

    Even=12;//enter Even numbers only

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


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


    Color=colorBrightGreen;//select Moving average line color
    tickercolor=colorBlack;//select price color

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


  1. Afwma - I Forum di Investireoggi

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: