AveragePrice

See Also...

Related Topics

 

 

Description

This formula calculates an average price.

 

 

Formula

AveragePrice(SERIES, bate, length, targetBar)=begin

  start=targetBar

  finish = length + targetBar

  total=0

  average=0

 

  if length > 0 then begin

    while start < finish do begin

      total = total + GetPrice(series, bate, start, targetBar)

      start=start+1

    end

    average = total / length

  end

  average

end

 

 

Parameters

SERIES

The SERIES directive makes this formula available as a Formula Study. SERIES refers to the instrument in a chart. SERIES does not become a study parameter.

 

bate

The price you want to average. There is no default value.

 

length

The number of periods, or bars, you want to average. There is no default value.

 

targetBar

Pass 0 to this argument. There is no default value.

 

 

Return Value

An average of prices.

 

 

Examples

...

  UpEQ = Summation(instrument, BATE_INDEXxCLOSE, Length, targetBar) - Length * AveragePrice(instrument, BATE_BARINDEX, Length, targetBar) * AveragePrice(instrument, BATE_CLOSE, Length, targetBar)

...

 

 

Comments

This formula is has a specialized role in the RSquared formula. Use Average for simple averaging.

 

©2008 Aspen Research Group, Ltd. All rights reserved. Terms of Use.