All indicators

Median

The middle value of the source over a rolling window, a centre line that a single outlier bar cannot drag around the way it drags a mean.

BTCUSD1h
Fixed data to Oct 6, 2026, UTC
Loading the chart

The Median study sorts the last Period values of the source and plots the one in the middle. When the window holds an odd number of values that is the single middle value; when it holds an even number it is the average of the two middle values.

Unlike a simple moving average, the median ignores how far the extreme values sit from the centre. One bar with a huge wick or a bad print moves a mean by its full size divided by the window, but it moves the median by at most one rank. That makes the line a steadier estimate of where price has typically been.

The study answers from the first bar. Before the window has filled it takes the median of the bars that exist so far, and any absent value in the window is skipped rather than counted.

How to read Median

Read the median as the typical price of the recent window. A current value above the line is higher than at least half of the recent values, and a value below it is lower than at least half of them. Because it moves in steps rather than smoothly, it often stays flat for several bars and then jumps, which is normal for a rank statistic.

It lags in a strong trend just as an average does, and after a sudden jump it moves to the new level only once more than half of the window's values sit there.

Settings

Source
The price series the median is taken from, such as the close or the bar midpoint.
Period
How many recent bars are ranked. A longer period gives a steadier line that responds later.

Frequently asked questions

Why does the line sometimes stay flat and then jump?

The median is one of the window's own values, or the average of two of them, so it only changes when the middle rank changes. A new bar that lands well away from the centre may not move it at all.

How is it different from a simple moving average?

An average adds up every value, so a single extreme bar pulls it by its full size. The median only looks at order, so the same bar moves it by at most one position in the sorted window.

Does it have a warmup period?

No. On early bars it takes the median of however many bars exist, so the first value is simply the first bar's source.

Write your own in OpenScript

Every study here is plain OpenScript. Change a setting, combine two, or turn one into a strategy, then backtest it in /trading and run it in sandbox trading (analyzer mode in OpenAlgo) before going further.