2012.07.06 11:30

- Views:
- 8098
- Rating:

This indicator computes the median of odd span. The median is described as the numerical value separating the higher half of a sample, or a probability distribution, from the lower half. It is often considered as one of the **most robust smoothing operator** in the presence of outlier values, and particularly more robust than the mean.

Calculation of medians is a popular technique in summary statistics and summarizing statistical data. A very nice property of the median is that the **distance between the median and the mean is bounded by one standard deviation**. The median is also a **non-lagging** operator.

The paradox is that it is almost impossible to find the median indicator in trading softwares. Moreover, straightforward implementations rely on array sorts, which is a very slow operation that does not scale up to long timeseries.

I therefore designed this running median operator which is incremental and therefore very fast. It is under the GNU public license.

Last comments | Go to discussion(14)hindmost| 13 Jul 2012 at 10:37Try this, as there are 2 arguments to RunMedian

If the error is still present, I will look more thoroughly.

mrmedia:i get 2147483647 for this in an EA.

"You need to apply an indicator buffer value next to IndVal[] value." NOPE

For some reason this fails to paint when backtesting

willgart| 14 Jul 2012 at 01:07I add this line in the code: (just before runmedian(limit);)

if(limit<period)limit=period;

because the indicator did not redraw on a new candle (as well as the current one)

with this I force the indicator recalculate the lastest candles and fill the working buffer, else the current and new candles will not have enough info to evaluate the median value.

hindmost| 14 Jul 2012 at 09:29for (cursor=limit;cursor>=0;cursor--) {

->

for (cursor=MathMax(limit,period);cursor>=0;cursor--) {willgart:I add this line in the code: (just before runmedian(limit);)

if(limit<period)limit=period;

because the indicator did not redraw on a new candle (as well as the current one)

with this I force the indicator recalculate the lastest candles and fill the working buffer, else the current and new candles will not have enough info to evaluate the median value.

mql4_comments| 19 Sep 2013 at 22:13In metatrader 4 the median stops drawing, refresh doesn't work. The only way to let it redraw is to open the indicators list and adjust the median and press ok. Could there be an update please?

Later.....Oh sorry, I copied the text now and it worked, thank you. But the text isn't in the download yet.

mql4_comments| 3 Oct 2013 at 20:47