Hi Searnp -- The User's Guide states: AFL Function Reference - MEDIAN *MEDIAN *- calculate median (middle element)
*Statistical functions *(AFL 2.5) *SYNTAX* *Median( array, period ) * *RETURNS* ARRAY *FUNCTION* The Median function - finds median (middle element) value of the *array* over *period*elements. *EXAMPLE* // list only symbols which volume is greater than // median Volume from past 50 days *Filter* = *Volume* > Median( *Volume*, 50 ); AddColumn( *V*, "Volume" ); Period must be a scalar -- a constant. When you run this code: RM = Median(Close, BarIndex() + 1); The entire Close array is passed to the Median function at one time. The value of BarIndex changes with each element of the Close array. Looked at simplistically, the afl processor does not know which value of BarIndex to use, so it coughs. You will have to write your own function using looping code. Before you start, are you certain that you want the median value of an expanding list of data values? Today's value will depend on how much data was loaded, which is generally not a good programming or systems idea. Will Median(C,50), or some variation, give you what you need? Thanks, Howard On Mon, Nov 3, 2008 at 11:26 AM, searnp <[EMAIL PROTECTED]> wrote: > I am trying to calculate a running median that starts at bar 0. > > Code: > > RM = Median(Close, BarIndex() + 1); > > > Then I get the following error message: > > Error 5. Argument #2 has incorrect type (the function expects different > argument type here) > > > I am using "Barindex() + 1" to get a running count at each bar to be used > in the median's lookback period. Is there a way to implement this? > > Thanks. > >
