Volume adjusted mov. av. formula

Discussion in 'Trading Software' started by leen, May 31, 2002.

  1. leen



    To build an indicator and strategy that uses a volume adjusted moving average, I heavily searched the internet, but I couldn't get hold of the formula. :(

    Who can help me and provide me the formula (easylanguage) ?

    Thanks :p
  2. (easy language)....moving average....it sounds like your trying to pick up a blond.
  3. Pretty simple -

    Just add up each bar's closing price times its volume in the MA's length and divide the total by the total volume in the MA's length and then divide that by the # of bars in the MA's length

    Something like this (don't use/like EasyLanguage - but you should be able to adapt as necessary):

    Function VolWeightMA(n as long) as double 'where n=# of periods in MA
    dim VW as double, V as double

    VW=0 'Used to aggregate Volume*Price
    V=0 'Used to aggregate Volume

    for i=lastbar to lastbar-n+1 step -1 'lastbar=# of last bar in series
    VW=VW+Volume(i)*ClosePrice(i) 'i=bar #
    next i


    End Function

    'Note for smplicity of notation Volume(n)=volume of the Nth bar and ClosePrice(n)=closing price of the Nth bar
  4. leen


    Many thanks ArchAngel ,

    I have studied you formula and build the Function in EL as follows:

    Input: Price(NumericSeries), Length(NumericSimple);
    Variable: VA(0), TotalVolume(0), n(0);

    VA = 0;
    TotalVolume = 0;

    For n = 0 to Length
    VA = VA + (Price[n] * Volume[n]);
    TotalVolume = TotalVolume + Volume[n];

    VolumeAdjustedMA = VA / TotalVolume;

    I removed the division of # of bars, so when printing this function as an indicator, you have a direct relation with the Close price.
    Then you can also compare this indicator with a normal MA.

  5. leen - sorry, you're right. I mistakenly included the extra divide by N (shouldn't be in the formula).
  6. billm


    I have entered this code into TradeStation 2000i using Easy Language and the moving average line it produces is alot different to the Volume Adjusted Moving Average that MetaStock 5.1 plots for the same data, comparing the 2 charts.

    As I dont have Meta 5.1, I cannot verify if they are using a different code for the indicator or that the difference is down to data differences between mine and the other computer.

    Can anyone verify that this is the same code that Metastock uses or better still, if you have TradeStation and MetaStock5.1 perhaps you can test it out and let me know.

    Many thanks :)
  7. billm