Elastic Volume Weighted Moving Average

Folks, I am trying to create this MA so that it displays on my chart and I am able to change parameter periods. Code looks correct to me and is working with other MAs in this format? Any ideas on why this produces a flat line at the bottom of the chart?

_SECTION_BEGIN("eVWMA");

/* Elastic Volume Weighted Moving Average by Christian B. Fries */
function eVWMA(array, N)
{
  result[0] = array[0];
  for (i = 1; i < BarCount; i++) 
  {
    result[i] = ((N - Volume[i]) * result[i - 1] + Volume[i] * array[i]) / N;
  }
  return result;
}

Period = Param("Periods", 15, 2, 300, 1, 10 );
Plot( eVWMA(C, Period ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 

_SECTION_END();

@topmarx, you have misunderstood the indicator and used the wrong values in the parameters.

If you re-read Fries paper’s (try Technical Analysis of Stocks and Commodities June 2001) you will see that he writes “defining the averaging period by volume rather than days. Calculate the volume-weighted moving average over the last trades (or bars, days, weeks, or months) with a total volume of, say, N, where N is a fixed number that has an impact on the length of the averaging period similar to the effect the number of days in other forms of averages has”

So your use of lookback period in bars is wrong

Period = Param("Periods", 15, 2, 300, 1, 10 );
Plot( eVWMA(C, Period )

Even if you were unfamiliar with the indicator your code can illustrate how wrong you are, because in your formula you have N - Volume. If N is some small number of bars (for example 20) then 20 -3,000,000 (as an example of Volume of 3 million) makes no sense.

 result[i] = ((N - Volume[i]) * result[i - 1] + Volume[i] * array[i]) / N;

His paper has this excerpt as well as an example spreadsheet,

image

I am not an expert on this indicator and have very little familiarity with its use. I have an AmiBroker afl that is one interpretation for this indicator, but I did not write it and had not saved the source so am unable to give proper credit to the author, nor can I confirm that it is the correct interpretation of the Fries work.

// Elastic Volume Weighted Moving Average by Christian B. Fries
// Technical Analysis of Stocks and Commodities June 2001


function eVWMA( array, N )
{
    result[0] = array[0];

    for( i = 1; i < BarCount; i++ )
    {
        result[i] = ( ( N - Volume[i] ) * result[i - 1] + Volume[i] * array[i] ) / N;
    }

    return result;
}

Price = ParamField( "Price field", -1 );
N = Param( "# of shares multiplier", 1, -100, 100, 1 );
Plot( eVWMA( Price, 10 ^ ( N / 100 ) * LastValue( Highest( Volume ) ) ), "Elastic Volume Weighted Moving Average", colorAqua, styleLine );

If it is of any help the Metastock people coded it this way at that time,
n := Input(“Enter the number of shares: “,1,1000000,1);
eVWMA := ((n-V)PREV+(VC))/n;

8 Likes

eVWMA is nothing more than one form of -Single Pole Impulse Response Filter- named as well as -Adaptive Moving Average- in which the alpha coefficient is defined by the ratio of shares traded in a given time (preferably daily or tick) over all available shares for trading (SharesFloat):

N                  =      Param("Periods", 15, 2, 300, 1, 10 );
Fn_floatcoeff      =      Volume / GetFnData( "Float" );
Nday_floatcoeff    =      Volume / sum( Volume, N );

Amibroker already have 3 inbuilt indicators to achieve this without rewriting all the wheel and waste compute resources:

AMA__evwma  =  AMA( Close, *_floatcoeff );
AMA2_evwma  =  AMA2( Close, *_floatcoeff, 1 - *_floatcoeff );
IIR___evwma =  IIR( Close, *_floatcoeff, 1 - *_floatcoeff );

Faries defined that a reliable calculation MUST BE sustained with Times&Sales data (RT tick) but given how expensive this is, minimum a true float array could be helpful for an EOD calculation.

2 Likes