GetMedian()
Previous Topic  Next Topic 

Definition
Returns the median value of the specified series over the specified look back period. This method will sort the values of the specified look back period in ascending order and return the middle value. If an even number is passed in, the average of the two middle values in the sorted values will be returned.

Method Return Value

A double value representing the median price.


Syntax
GetMedian(IDataSeries series, int lookBackPeriod)


Method Of

Custom Indicator, Custom Strategy


Parameters

series

Any DataSeries type object such as an indicator, Close, High, Low etc..

lookBackPeriod

Number of bars back to include in the calculation


Examples

// Print the median price of the last 10 open prices
if (GetMedian(Open, 10))
    Print("The median of the last 10 open prices is: " + GetMedian(Open, 10).ToString());